简体   繁体   中英

iOS connection to a JSON API

I'm just writing the planning for an iPhone app I'm making to manage your repositories on GitHub. This is for a University assignment.

Can I OAuth from Objective-C and how would it work? Would it just be a 'Login with GitHub' button to load an in-built browser or would it be a username / password combo?

Am I able to get the resulting token back from this and store it using Core Data until the user forcibly logs out?

You definitely can - it's possible to either go through GitHub's web based authentication flow, or use their 'non web application' alternative. Both are detailed here .

However, a number of developers have already created GitHub API libraries for various languages, including this one for Objective-C that is listed on GitHub's own libraries page. You may find it a lot easier, and you could always modify it (and hopefully contribute your changes back!) if you need to do things that the library doesn't support.

You can have a look at the authentication code I'm using in iOctocat: https://github.com/dennisreimann/ioctocat

Under the hood I'm using AFNetworking with its OAuth2 extension, which makes most of the communication very easy. The custom stuff the app is doing can be found here: https://github.com/dennisreimann/ioctocat/blob/master/Classes/GHBasicClient.m

Hope this helps you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM