AFOAuth2Manager 0,0,0,1,0,2 travis-ci CocoaPods

AFNetworking Extension for OAuth 2 Authentication

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

AFHTTPSessionManager *manager =
    [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];

[manager.requestSerializer setAuthorizationHeaderFieldWithCredential:credential];

[manager GET:@"/path/to/protected/resource"
  parameters:nil
    progress:nil
     success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
         NSLog(@"Success: %@", responseObject);
     }
     failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull 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.

License

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

Related Repositories

AFOAuth2Manager

AFOAuth2Manager

AFNetworking Extension for OAuth 2 Authentication ...

AFOAuth2Manager

AFOAuth2Manager

AFNetworking Extension for OAuth 2 Authentication ...

AFOAuth2Manager

AFOAuth2Manager

AFNetworking Extension for OAuth 2 Authentication ...


Top Contributors

mattt kcharwood conradev ejensen iamcam fjaeger gabrielrinaldi brendanjerwin ldrr gertig imanzarrabian echoz juanuribeo13 hwaxxer priteshshah1983 seut svenmuennich thibaut-jarosz westonplatter

Releases

-   3.0.0 zip tar
-   2.2.0 zip tar
-   2.1.0 zip tar
-   2.0.0 zip tar
-   1.2.1 zip tar
-   1.0.0 zip tar
-   0.1.2 zip tar
-   0.1.1 zip tar