Latest | 1.0.0 |
---|---|
Homepage | https://github.com/AFNetworking/AFOAuth1Client |
License | MIT |
Platforms | ios 5.0, osx 10.7, requires ARC |
Dependencies | AFNetworking |
Authors |
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.
Latest podspec
{ "name": "AFOAuth1Client", "version": "1.0.0", "summary": "AFNetworking Extension for OAuth 1.0a Authentication.", "homepage": "https://github.com/AFNetworking/AFOAuth1Client", "social_media_url": "https://twitter.com/AFNetworking", "license": "MIT", "authors": { "Mattt Thompson": "[email protected]" }, "source": { "git": "https://github.com/AFNetworking/AFOAuth1Client.git", "tag": "1.0.0" }, "source_files": "AFOAuth1Client", "requires_arc": true, "platforms": { "ios": "5.0", "osx": "10.7" }, "ios": { "frameworks": [ "MobileCoreServices", "SystemConfiguration", "Security", "CoreGraphics" ] }, "osx": { "frameworks": [ "CoreServices", "SystemConfiguration", "Security" ] }, "dependencies": { "AFNetworking": [ "~> 1.3" ] }, "prefix_header_contents": "#importnn#define _AFNETWORKING_PIN_SSL_CERTIFICATES_nn#if __IPHONE_OS_VERSION_MIN_REQUIREDn #import n #import n #import n#elsen #import n #import n #import n#endifn" }
Sat, 27 Feb 2016 13:16:03 +0000