Giter Site home page Giter Site logo

simple-oauth1's Introduction

simple-oauth1

Simple code for authenticating with OAuth 1.0a service providers

Built for iOS 6 with blocks and ARC.

AFNetworking (https://github.com/AFNetworking/AFNetworking) have some awesome methods for handling url parameters, which has been used in the project. Also a nice oauth signature method from OAuthConsumer (http://code.google.com/p/oauthconsumer/) has been used.

Currently URL's are set for LinkedIn API, but has been tested against Twitter and Tumblr.

How to configure the sample project

  1. Register and app here: https://www.linkedin.com/secure/developer (or other OAuth 1.0a service)

  2. Insert your Client ID and Client Secret in OAuth1Controller.m (and change the authentication-url and token-url if you're not using LinkedIn API)

  3. Run the app. Tap the login button and authorize the app

  4. After successfull authentication, tap the "API Request" button to test an API get request. Currently it is set (in ViewController.m) to pull your LinkedIn profile or find an appropriate API call on your OAuth1.0a service provider.

Integrate in your own project

Copy the classes in the "OAuth1" group of the sample project to your project. Create a new OAuth1Controller object and run the method loginWithWebView:completion: by providing a UIWebView to handle the authorization part where the user puts in his/her credentials. You have to have a strong reference to your OAuth1Controller object. Example below from the sample project.

LoginWebViewController *loginWebViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"loginWebViewController"];
[self presentViewController:loginWebViewController
                   animated:YES
                 completion:^{
                     [self.oauth1Controller loginWithWebView:loginWebViewController.webView completion:^(NSDictionary *oauthTokens, NSError *error) {
                         if (!error) {
                             // Store your tokens for authenticating your later requests, consider storing the tokens in the Keychain
                             NSLog(@"Success: %@", oauthTokens);
                         }
                         else
                         {
                             NSLog(@"Error authenticating: %@", error.localizedDescription);
                         }
                         [self dismissViewControllerAnimated:YES completion: ^{
                             self.oauth1Controller = nil;
                         }];
                     }];
                 }];

The files inside Crypto are standard files for creating the signature.

Creator

Christian Hansen
@chrhansen

License

Simple-oauth1 is available under the MIT license.

simple-oauth1's People

Contributors

kmonaghan avatar

Watchers

Tiago José Pires Oliveira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.