I am trying to consume rest based web service for the first time so I searched for tutorials and examples I found these link1 & link2
My colleague created a simple rest service, first without authentication I successfully fetched the json formatted data but same service with form based authentication I am unable to call it which include adding id, password in http header [request addValue:#"id:password" forHTTPHeaderField:#"Authorization"];, using willSendRequestForAuthenticationChallenge but no success.
I also found tons of RestKit articles but its problem is its too heavy, my requirement for project is not that complex.
Please any one can provide good and complete tutorial or any way to import Restkit required functionality not the whole 16mb framework?
I recommend AFNetworking ,it is easy to integrate and very reliable.
You can use AFURLConnection -setAuthenticationChallengeBlock: to respond to authentication challenges.
Related
I am really stuck and I need your help.
I am working on my web and iOS application. I used also Django to save users to database.
Login function is already working on my web (HTML) but I really don ´t know how to create function to iOS app (Swift).
I enclose also screens of Api HTML and Swift Code. Now it's working only with Facebook. User can sign in using Facebook and order something using iOS App.
I would really like to do the same but with Login Function (not using FB). I hope you can help me. I don't know how to do it and I've read a lot of web.
I would be really glad to you if you can help me.
Please HELP !
Thank you so much.
Image 1 - HTML Urls
Image 2 - Apis
Image 3 - Forms
Image 4 - social_auth_piplines
Image 5 - Models
Image 6 - Swift Apis
This is very broad. There is a lot of questions that need to be answered before I can provide a solid answer but I'll give you an idea on what you have to do.
API
First of all you need an api that serializes the data from your database so it acts as a layer between your app and backend. If you are using Django then take a look at Django Rest Framework which will help you achieve that.
Networking Framework
After setting up your api you need a networking layer in Swift to help you communicate with your api. You can use Swift's URLSession or you can download Alamofire to make things a bit simpler. What a networking layer basically does is fetch the json provided by your Django app and changes it to a Dictionary so you can use it.
In your django Application, you are to specify restframework Authentication to Token. You can get more info about token with django rest auth.
In your iOS.What you need to do is create an AuthServices model. Now in your AuthServices model, you create your login function.
For your login function I assume you are very familiar with Alamofire so you make an API request which would take your parameters and your header which I assume contains a token should also be specified.
Keep your server running and run the application locally if you wish and take username and password with text fields. This should help you go on with it.
I'm trying to create an application that needs to use a backend. That backend will be used to sync an app created (initially) for iOS, macOS, watchOS. Hope to expand after.
Firebase looks like a nice tool to do that, but it only has so many SDK's. I'd like to unify the codebase as much as possible to utilize code reuse.
Seems like their REST API is the way to go: I just create a framework using REST and we're off: https://firebase.google.com/docs/database/rest/start
However, their authentication doesn't seem to support REST.
How do I get around this limitation? What should I do to get a valid auth token that Firebase will understand?
Please keep in mind that I'm not very experienced with web stuff and even after reading a lot of articles, I'm still confused about how to exactly approach this. For example, this user had a similar concern, but I'm not exactly understanding the answer.
Firebase now officially supports REST API:
https://firebase.google.com/docs/reference/rest/auth/
You can query the Firebase Auth backend through a REST API. This can be used for various operations such as creating new users, signing in existing ones and editing or deleting these users.
How can I access the Appery.io (or any future db) that is exposed to the REST API using RoR?
So I have an app i built using Appery.io and I also created a test app using RoR that I would like to use to pull information from the Appery.io db and display it on my RoR app.
I am somewhat familiar with REST and get the idea of what it is doing but I am not to certain on how to connect or make a connection from my RoR app to my Appery.io app. Appery.io has the following documentation for their db api, Appery.io DB API .
I have been looking around and also have seen people mention the following gems for HTTP request:
Weary
HTTParty
RestClient
Would I use one of those? I also read about using Active Resource as a possible solution?
Any help with getting started or a tutorial or article to point me in the right direction would be very helpful.
Thanks!
You won't be establishing an ongoing connection, each request/response will be a single query to your Appery DB. You authenticate those calls using a custom header with API key as defined in the documentation. There's an example using cURL that might be a good place to start playing with the API before you pull it into your RoR app. That example shows you how to get your key, too.
It looks like you can use the predefined APIs, or you can define a custom REST API associated with your Appery app? Instructions for building an API appear to be here.
Once you get the calls working from cURL (or other web request client of your choice), adding the calls to the RoR app should be more straightforward. Any of those gems could probably ease that process: I've only used RestClient personally, but found it very straightforward.
Any of those call methods (cURL, other clients, the gems, etc) will allow you specify your URI, method (e.g. GET or POST), headers, request body (where appropriate), and will allow you to examine your response. Take a look at the gem documentation to see how those map exactly - it will vary slightly from tool to tool.
If you don't have prior experience with calling external APIs, and would like a conceptual explanation, I like this article as a (very short!) beginner's guide.
It's now trivial to create a web app that sits atop Parse.com. Now that I have this webapp, I want to expose parts of it to other developers via an oauth accesible api. So, they can develop an app that lets my site users 'give them permission' via oauth and they can now access the api.
How would I start going about doing this?
Update: After #Mubix response, I felt the following clarification would help
Currently I am accessing Parse from the server via a REST api, to get around any javascript security issues re:api keys etc. So, the api would be served of a server other than Parse. Also, the server code is in javascript / nodejs. I came across https://github.com/jaredhanson/oauth2orize which seems a likely candidate, was wondering how others are doing it and if anyone has actually gone a further step and integrated Parse access.
Hmmm .. Intereesting question!
Legal:
First of all their ToS doesn't seem to prohibit what you are trying to do but you should read it carefully before you start.
Implementation:
While parse doesn't provide feature to build your own APIs you could implement something yourself. You could treat the third party developers as users of your app. And you can use the ACL to control access.
Problems:
I don't see any way to implement oAuth entirely within parse.
How will third party apps access your API? Ideally you would like them to use a REST interface but with the parse.com REST API you won't be able to manage access to different parts of your data.
Conclusion:
It seems like too much trouble to implement the API entirely within parse. I would suggest that you write a thin API layer that takes care of auth and uses parse as the backend. You can use one of the service side libraries available for parse. eg. PHP Library, Node Parse.
I am quite confused on what REST API to follow that will sync with RestKit.
I have a problem in making a put/post/delete request.
One of the REST API I follow is from NetTuts which I found very hard to sync with RestKit.
Any suggestions? Thank you so much!
RestKit is a generalized framework for consuming JSON/XML over HTTP. It will interoperate with any backend, providing the payload can be expressed as key-value coding key paths.