Skip to content
AFNetworking Extension for OAuth 1.0a Authentication
Objective-C Ruby
Find file
Latest commit b5a17d9 @mattt mattt Bumping version to 1.0.0
Failed to load latest commit information.
AFNetworking @ 5266874 Updating AFNetworking to 1.3.4
AFOAuth1Client.xcworkspace Refactoring projects and directory structure
AFOAuth1Client Adding documentation
Twitter OSX Example Client Updating project to latest recommended settings
Twitter iOS Example Client Minor refactoring & reformatting merge
.gitignore Add gitignore
.gitmodules Removed previous example projects, added new ones, upgraded AFNetwork…
AFOAuth1Client.podspec
LICENSE Updating copyright in preamble
README.md Update README

README.md

AFOAuth1Client

AFOAuth1Client is an extension for AFNetworking that simplifies the process of authenticating against an OAuth 1.0a provider.

Usage

NSURL *baseURL = [NSURL URLWithString:@"https://twitter.com/oauth/"];
AFOAuth1Client *OAuth1Client = [[AFOAuth1Client alloc] initWithBaseURL:baseURL
                                                                   key:@"..."
                                                                secret:@"..."];

Register your application to launch from a custom URL scheme, and use that with the path /success as your callback URL. The callback for the custom URL scheme should send a notification, which will complete the OAuth transaction.

NSURL *callbackURL = [NSURL URLWithString:@"x-com-YOUR-APP-SCHEME://success"];
[OAuth1Client authorizeUsingOAuthWithRequestTokenPath:@"/request_token"
                                userAuthorizationPath:@"/authorize"
                                          callbackURL:callbackURL
                                      accessTokenPath:@"/access_token"
                                              success:^(AFOAuth1Token *accessToken) {
                                                  NSLog(@"Success: %@", accessToken);
                                              }
                                              failure:^(NSError *error) {
                                                  NSLog(@"Error: %@", error);
                                              }];

Responding to the custom URL scheme on iOS:

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)URL
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
    NSNotification *notification =
        [NSNotification notificationWithName:kAFApplicationLaunchedWithURLNotification
                                      object:nil
                                    userInfo:@{kAFApplicationLaunchOptionsURLKey: URL}];
    [[NSNotificationCenter defaultCenter] postNotification:notification];

    return YES;
}

Contact

Mattt Thompson

License

AFOAuth1Client is available under the MIT license. See the LICENSE file for more info.

Something went wrong with that request. Please try again.