• This repository has been archived on 17/Jan/2023
  • Stars
    star
    209
  • Rank 182,364 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AFNetworking Extension for OAuth 1.0a Authentication

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.

More Repositories

1

AFNetworking

A delightful networking framework for iOS, macOS, watchOS, and tvOS.
Objective-C
33,333
star
2

AFIncrementalStore

1,687
star
3

AFOAuth2Manager

AFNetworking Extension for OAuth 2 Authentication
Objective-C
1,184
star
4

AFNetworkActivityLogger

AFNetworking 3.0 Extension for Network Request Logging
Objective-C
560
star
5

AFAmazonS3Manager

AFNetworking Client for the Amazon S3 API
Objective-C
363
star
6

fastlane

A fastlane setup to deploy Objective-C and Swift frameworks.
Ruby
252
star
7

Xcode-Project-Templates

Objective-C
222
star
8

AFHTTPRequestOperationLogger

AFNetworking Extension for HTTP Request Logging
Objective-C
215
star
9

AFJSONRPCClient

Client for interacting with JSON-RPC APIs
Objective-C
189
star
10

AFgzipRequestSerializer

gzip Request Serializer for AFNetworking
Objective-C
167
star
11

AFRocketClient

152
star
12

AFOnoResponseSerializer

An XML and HTML response serializer for AFNetworking 2.0, using Ono
Objective-C
113
star
13

AFNetworking-ASIHTTPRequest

75
star
14

AFCoreImageResponseSerializer

AFNetworking 2.0 Serialization Module to apple Core Image Filters to Images
Objective-C
68
star
15

AFMsgPackSerialization

AFNetworking 2.0 Serialization Module for MsgPack
Objective-C
65
star
16

AFWebDAVManager

AFNetworking manager for WebDAV
Objective-C
64
star
17

WebKit-AFNetworking

AFNetworking Extensions for WebKit
Objective-C
48
star
18

AFContentRequestOperations

Legacy content-specific request operation subclasses re-implemented with AFNetworking 2.0 APIs
Objective-C
25
star
19

AFCollectionJSONRequestOperation

AFNetworking Extension for Collection+JSON Hypermedia
20
star
20

afnetworking.com

Source code for AFNetworking.com
CSS
8
star