Latest 0.3.6
License MIT
Platforms ios 6.0, osx 10.8, requires ARC
Dependencies AFNetworking



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.

Here’s how to create a client and authenticate:

AFOAuth1Client *twitterClient = [[AFOAuth1Client alloc] initWithBaseURL:[NSURL URLWithString:@""] key:@"..." secret:@"..."];

// Your application will be sent to the background until the user authenticates, and then the app will be brought back using the callback URL
[self.twitterClient authorizeUsingOAuthWithRequestTokenPath:@"/oauth/request_token" userAuthorizationPath:@"/oauth/authorize" callbackURL:[NSURL URLWithString:@"af-twitter://success"] accessTokenPath:@"/oauth/access_token" accessMethod:@"POST" scope:nil success:^(AFOAuth1Token *accessToken, id responseObject) {
    NSMutableURLRequest *request = [self.twitterClient requestWithMethod:@"GET" path:@"statuses/user_timeline.json" parameters:nil];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperationManager manager] HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"Success: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", [error localizedDescription]);
    [manager.operationQueue addOperation:operation];
} failure:^(NSError *error) {
    NSLog(@"Error: %@", error);

Here’s how to respond 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:[NSDictionary dictionaryWithObject:url forKey:kAFApplicationLaunchOptionsURLKey]];
    [[NSNotificationCenter defaultCenter] postNotification:notification];

    return YES;


Joel Chen


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

Latest podspec

    "name": "AF2OAuth1Client",
    "version": "0.3.6",
    "summary": "AFNetworking 2 Extension for OAuth 1.0a Authentication.",
    "homepage": "",
    "social_media_url": "",
    "license": "MIT",
    "authors": {
        "Mattt Thompson": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.3.6"
    "source_files": "AF2OAuth1Client",
    "requires_arc": true,
    "platforms": {
        "ios": "6.0",
        "osx": "10.8"
    "ios": {
        "frameworks": [
    "osx": {
        "frameworks": [
    "dependencies": {
        "AFNetworking": [
            "~> 2.0"

Pin It on Pinterest

Share This