• This repository has been archived on 17/Jan/2023
  • Stars
    star
    1,184
  • Rank 39,149 (Top 0.8 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 13 years ago
  • Updated over 2 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 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.

More Repositories

1

AFNetworking

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

AFIncrementalStore

1,687
star
3

AFNetworkActivityLogger

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

AFAmazonS3Manager

AFNetworking Client for the Amazon S3 API
Objective-C
364
star
5

fastlane

A fastlane setup to deploy Objective-C and Swift frameworks.
Ruby
251
star
6

Xcode-Project-Templates

Objective-C
221
star
7

AFHTTPRequestOperationLogger

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

AFOAuth1Client

AFNetworking Extension for OAuth 1.0a Authentication
Objective-C
210
star
9

AFJSONRPCClient

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

AFgzipRequestSerializer

gzip Request Serializer for AFNetworking
Objective-C
166
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
63
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