FWOAuth2Manager
@interface FWOAuth2Manager : FWHTTPSessionManager
FWOAuth2Manager
-
The service provider identifier used to store and retrieve OAuth credentials by
FWOAuthCredential. Equivalent to the hostname of the clientbaseURL.Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull serviceProviderIdentifier; -
The client identifier issued by the authorization server, uniquely representing the registration information provided by the client.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull clientID; -
Whether to encode client credentials in a Base64-encoded HTTP
Authorizationheader, as opposed to the request body. Defaults toYES.Declaration
Objective-C
@property (nonatomic) BOOL useHTTPBasicAuthentication;
-
Creates and initializes an
FWOAuth2Managerobject with the specified base URL, client identifier, and secret.Declaration
Objective-C
+ (nonnull instancetype)managerWithBaseURL:(nonnull NSURL *)url clientID:(nonnull NSString *)clientID secret:(nonnull NSString *)secret;Parameters
urlThe base URL for the HTTP client. This argument must not be
nil.clientIDThe client identifier issued by the authorization server, uniquely representing the registration information provided by the client. This argument must not be
nil.secretThe client secret.
Return Value
The newly-initialized OAuth 2 manager
-
Undocumented
Declaration
Objective-C
+ (instancetype)managerWithBaseURL:(NSURL *)url sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration clientID:(NSString *)clientID secret:(NSString *)secret; -
Initializes an
FWOAuth2Managerobject with the specified base URL, client identifier, and secret. The communication to to the server will use HTTP basic auth by default (use-(id)initWithBaseURL:clientID:secret:withBasicAuth:to change this).Declaration
Objective-C
- (nonnull id)initWithBaseURL:(nonnull NSURL *)url clientID:(nonnull NSString *)clientID secret:(nonnull NSString *)secret;Parameters
urlThe base URL for the HTTP manager. This argument must not be
nil.clientIDThe client identifier issued by the authorization server, uniquely representing the registration information provided by the client. This argument must not be
nil.secretThe client secret.
Return Value
The newly-initialized OAuth 2 client
-
Undocumented
Declaration
Objective-C
- (id)initWithBaseURL:(NSURL *)url sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration clientID:(NSString *)clientID secret:(NSString *)secret;
-
Creates and enqueues an
NSURLSessionTaskto authenticate against the server using a specified username and password, with a designated scope.Declaration
Objective-C
- (nonnull NSURLSessionTask *) authenticateUsingOAuthWithURLString:(nonnull NSString *)URLString username:(nonnull NSString *)username password:(nonnull NSString *)password scope:(nullable NSString *)scope success: (nonnull void (^)( FWOAuthCredential *_Nonnull __strong)) success failure:(nonnull void (^)( NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
usernameThe username used for authentication
passwordThe password used for authentication
scopeThe authorization scope
successA block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
failureA block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
-
Creates and enqueues an
NSURLSessionTaskto authenticate against the server with a designated scope.Declaration
Objective-C
- (nonnull NSURLSessionTask *) authenticateUsingOAuthWithURLString:(nonnull NSString *)URLString scope:(nullable NSString *)scope success: (nonnull void (^)( FWOAuthCredential *_Nonnull __strong)) success failure:(nonnull void (^)( NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
scopeThe authorization scope
successA block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
failureA block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
-
Creates and enqueues an
NSURLSessionTaskto authenticate against the server using the specified refresh token.Declaration
Objective-C
- (nonnull NSURLSessionTask *) authenticateUsingOAuthWithURLString:(nonnull NSString *)URLString refreshToken:(nonnull NSString *)refreshToken success: (nonnull void (^)( FWOAuthCredential *_Nonnull __strong)) success failure:(nonnull void (^)( NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
refreshTokenThe OAuth refresh token
successA block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
failureA block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
-
Creates and enqueues an
NSURLSessionTaskto authenticate against the server with an authorization code, redirecting to a specified URI upon successful authentication.Declaration
Objective-C
- (nonnull NSURLSessionTask *) authenticateUsingOAuthWithURLString:(nonnull NSString *)URLString code:(nonnull NSString *)code redirectURI:(nonnull NSString *)uri success: (nonnull void (^)( FWOAuthCredential *_Nonnull __strong)) success failure:(nonnull void (^)( NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
codeThe authorization code
uriThe URI to redirect to after successful authentication
successA block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
failureA block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
-
Creates and enqueues an
NSURLSessionTaskto authenticate against the server with the specified parameters.Declaration
Objective-C
- (nonnull NSURLSessionTask *) authenticateUsingOAuthWithURLString:(nonnull NSString *)URLString parameters:(nonnull NSDictionary *)parameters headers: (nullable NSDictionary<NSString *, NSString *> *)headers success: (nonnull void (^)( FWOAuthCredential *_Nonnull __strong)) success failure:(nonnull void (^)( NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded and set in the request HTTP body.
headersThe headers appended to the default headers for this request.
successA block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument: the OAuth credential returned by the server.
failureA block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error returned from the server.
FWOAuth2Manager Class Reference