Latest | 1.0.0 |
---|---|
Homepage | https://github.com/AFNetworking/AFOAuth2Client |
License | MIT |
Platforms | ios 5.0, osx 10.7, requires ARC |
Dependencies | AFNetworking |
Authors |
AFOAuth2Manager
AFOAuth2Manager is an extension for AFNetworking that simplifies the process of authenticating against an OAuth 2 provider.
Example Usage
Authentication
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/"];
AFOAuth2Manager *OAuth2Manager =
[[AFOAuth2Manager alloc] initWithBaseURL:baseURL
clientID:kClientID
secret:kClientSecret];
[OAuth2Manager authenticateUsingOAuthWithURLString:@"/oauth/token"
username:@"username"
password:@"password"
scope:@"email"
success:^(AFOAuthCredential *credential) {
NSLog(@"Token: %@", credential.accessToken);
}
failure:^(NSError *error) {
NSLog(@"Error: %@", error);
}];
Authorizing Requests
AFHTTPRequestOperationManager *manager =
[[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];
[manager.requestSerializer setAuthorizationHeaderFieldWithCredential:credential];
[manager GET:@"/path/to/protected/resource"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@", responseObject);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Failure: %@", error);
}];
Storing Credentials
[AFOAuthCredential storeCredential:credential
withIdentifier:serviceProviderIdentifier];
Retrieving Credentials
AFOAuthCredential *credential =
[AFOAuthCredential retrieveCredentialWithIdentifier:serviceProviderIdentifier];
Documentation
Documentation for all releases of AFOAuth2Manager are available on CocoaDocs.
Contact
Mattt Thompson
License
AFOAuth2Manager is available under the MIT license. See the LICENSE file for more info.
Latest podspec
{ "name": "AFOAuth2Client", "version": "1.0.0", "license": "MIT", "summary": "AFNetworking Extension for OAuth 2 Authentication.", "homepage": "https://github.com/AFNetworking/AFOAuth2Client", "social_media_url": "https://twitter.com/AFNetworking", "authors": { "Mattt Thompson": "[email protected]" }, "source": { "git": "https://github.com/AFNetworking/AFOAuth2Client.git", "tag": "1.0.0" }, "source_files": "AFOAuth2Client", "requires_arc": true, "dependencies": { "AFNetworking": [ "~>1.3" ] }, "platforms": { "ios": "5.0", "osx": "10.7" }, "deprecated": true, "deprecated_in_favor_of": "AFOAuth2Manager", "ios": { "frameworks": "Security" }, "prefix_header_contents": "#ifdef __OBJC__n #importn #if __IPHONE_OS_VERSION_MIN_REQUIREDn #import n #import n #elsen #import n #import n #endifn#endif /* __OBJC__*/n" }
Sun, 28 Feb 2016 03:29:03 +0000