RKOAuthClient Class Reference
Inherits from | NSObject |
Declared in | RKOAuthClient.h RKOAuthClient.m |
Overview
An OAuth client implementation that conforms to RKRequestDelegate to handle the authentication involved with the OAuth 2 authorization code flow.
RKOAuthClient sets up a pre-configured RKRequest and RKResponse handler to give easy access to retrieving an access token and handling errors through RKOAuthClientDelegate.
Example:
RKOAuthClient *oauthClient;
oauthClient = [RKClientOAuth clientWithClientID:@"YOUR_CLIENT_ID"
secret:@"YOUR_CLIENT_SECRET"
delegate:yourDelegate];
oauthClient.authorizationCode = @"AUTHORIZATION_CODE";
oauthClient.authorizationURL = @"https://foursquare.com/oauth2/authenticate";
oauthClient.callbackURL = @"https://example.com/callback";
[oauthClient validateAuthorizationCode];
From here, errors and the access token are returned through the implementation of RKOAuthClientDelegate specified.
For more information on the OAuth 2 implementation, see http://tools.ietf.org/html/draft-ietf-oauth-v2-22
Tasks
Creating an RKOAuthClient
-
– initWithClientID:secret:
Initialize a new RKOAuthClient with OAuth client credentials.
-
+ clientWithClientID:secret:
Creates and returns an RKOAuthClient initialized with OAuth client credentials.
General properties
-
delegate
A delegate that must conform to the RKOAuthClientDelegate protocol.
property
Client credentials
-
clientID
The ID of your application obtained from the OAuth provider
property -
clientSecret
Confidential key obtained from the OAuth provider that is used to sign requests sent to the authentication server.
property
Endpoints
-
authorizationURL
A string of the URL where the authorization server can be accessed
property -
callbackURL
A string of the URL where authorization attempts will be redirected to
property
Working with the authorization flow
-
authorizationCode
The authorization code is used in conjunction with your client secret to obtain an access token.
property -
accessToken
Returns the access token retrieved from the authentication server
property -
– validateAuthorizationCode
Fire a request to the authentication server to validate the authorization code that has been set on the authorizationCode property. All responses are handled by the delegate.
Properties
accessToken
Returns the access token retrieved from the authentication server
@property (nonatomic, readonly) NSString *accessToken
Declared In
RKOAuthClient.h
authorizationCode
The authorization code is used in conjunction with your client secret to obtain an access token.
@property (nonatomic, retain) NSString *authorizationCode
Declared In
RKOAuthClient.h
authorizationURL
A string of the URL where the authorization server can be accessed
@property (nonatomic, retain) NSString *authorizationURL
Declared In
RKOAuthClient.h
callbackURL
A string of the URL where authorization attempts will be redirected to
@property (nonatomic, retain) NSString *callbackURL
Declared In
RKOAuthClient.h
clientID
The ID of your application obtained from the OAuth provider
@property (nonatomic, retain) NSString *clientID
Declared In
RKOAuthClient.h
clientSecret
Confidential key obtained from the OAuth provider that is used to sign requests sent to the authentication server.
@property (nonatomic, retain) NSString *clientSecret
Declared In
RKOAuthClient.h
delegate
A delegate that must conform to the RKOAuthClientDelegate protocol.
@property (nonatomic, assign) id<> delegate
Discussion
The delegate will get callbacks such as successful access token acquisitions as well as any errors that are encountered. Reference the RKOAuthClientDelegate for more information.
See Also
Declared In
RKOAuthClient.h
Class Methods
clientWithClientID:secret:
Creates and returns an RKOAuthClient initialized with OAuth client credentials.
+ (RKOAuthClient *)clientWithClientID:(NSString *)clientID secret:(NSString *)secret
Parameters
- clientID
The ID of your application obtained from the OAuth provider.
- secret
Confidential key obtained from the OAuth provider that is used to sign requests sent to the authentication server.
Return Value
An RKOAuthClient initialized with a client ID and secret key.
Declared In
RKOAuthClient.h
Instance Methods
initWithClientID:secret:
Initialize a new RKOAuthClient with OAuth client credentials.
- (id)initWithClientID:(NSString *)clientID secret:(NSString *)secret
Parameters
- clientID
The ID of your application obtained from the OAuth provider.
- secret
Confidential key obtained from the OAuth provider that is used to sign requests sent to the authentication server.
Return Value
An RKOAuthClient initialized with a client ID and secret key.
Declared In
RKOAuthClient.h
validateAuthorizationCode
Fire a request to the authentication server to validate the authorization code that has been set on the authorizationCode property. All responses are handled by the delegate.
- (void)validateAuthorizationCode
See Also
Declared In
RKOAuthClient.h