MBGithubOAuthClient CocoaPod

Last week I got a chance to work on a simple project that involved GitHub. In that process I wrote a simple OAuth client that retrieves and stores GitHub access token in user defaults or keychain. John Clem took the time to help me with the creation of a CocoaPod for anyone interested in using it. So what is it, and how do you use it?

MBGithubOAuthClient is a dead simple wrapper class for performing OAuth requests on Github. In addition to authentication, it offers 2 ways of saving access token – user defaults or iOS keychain.

MBGithubOAuthClient takes advantage of NSURLSession and a singleton pattern to setup proper authorization requests. The easiest way to implement MBGithubOAuthClient is as a cocoa pod. Add the following line to your Podfile:

1. Register your app with GitHub to get client ID and client secret code.
2. Get a pointer to your singleton instance.

3. Setup initial parameters for GitHub access request (https://developer.github.com/v3/oauth/) and let MBGithubOAuthClient do the rest.

4. After successful authentication, you will be able to access your token by calling accessToken on your singleton.

Huge thanks to John for his help. Follow him on twitter.

Here is the link.

MBGithubOAuthClient CocoaPod

Leave a Reply

Your email address will not be published. Required fields are marked *