SFOAuthCoordinator Class Reference
Inherits from | NSObject |
---|---|
Conforms to | WKNavigationDelegate WKUIDelegate |
Declared in | SFOAuthCoordinator.h |
Overview
The SFOAuthCoordinator
class is the central class of the OAuth2 authentication process.
This class manages a WKWebView
instance and monitors it as it works its way
through the various stages of the OAuth2 workflow. When authentication is complete,
the coordinator instance extracts the necessary session information from the response
and updates the SFOAuthCredentials
object as necessary.
Warning: This class requires the following dependencies: the Security framework and either the NSJSONSerialization iOS 5.0 SDK class or the third party SBJsonParser class.
Other Methods
credentials
User credentials to use within the authentication process.
@property (nonatomic, strong, nullable) SFOAuthCredentials *credentials
Discussion
Warning: The behavior of this class is undefined if this property is set after authenticate
has been called and
authentication has started.
Warning: This property must not be nil
at the time the authenticate
method is called or an exception will be raised.
See Also
Declared In
SFOAuthCoordinator.h
delegate
The delegate object for this coordinator.
@property (nonatomic, weak) id<SFOAuthCoordinatorDelegate> delegate
Discussion
The delegate is sent messages at different stages of the authentication process.
See Also
Declared In
SFOAuthCoordinator.h
scopes
A set of scopes for OAuth. See: https://help.salesforce.com/apex/HTViewHelpDoc?language=en&id=remoteaccess_oauth_scopes.htm
@property (nonatomic, copy, nullable) NSSet *scopes
Discussion
Generally you need not specify this unless you are using something other than the “api” scope. For instance, if you are accessing Visualforce pages as well as the REST API, you could use: [@“api”, @“visualforce”]
(You need not specify the “refresh_token” scope as this is always requested by this library.)
If you do not set this property, the library does not add the “scope” parameter to the initial OAuth request, which implicitly sets the scope to include: “id”, “api”, and “refresh_token”.
Declared In
SFOAuthCoordinator.h
timeout
Timeout interval for OAuth requests.
@property (nonatomic, assign) NSTimeInterval timeout
Discussion
This value controls how long requests will wait before timing out.
Declared In
SFOAuthCoordinator.h
view
View in which the user will input OAuth credentials for the user-agent flow OAuth process.
@property (nonatomic, readonly, null_unspecified) WKWebView *view
Discussion
This is only guaranteed to be non-nil
after one of the delegate methods returning a web view has been called.
See Also
Declared In
SFOAuthCoordinator.h
asWebAuthenticationSession
Auth session through which the user will input OAuth credentials for the user-agent flow OAuth process.
@property (nonatomic, readonly, null_unspecified) ASWebAuthenticationSession *asWebAuthenticationSession
Declared In
SFOAuthCoordinator.h
userAgentForAuth
The user agent string that will be used for authentication. While this property will persist throughout the lifetime of the coordinator object, the user agent configured for the system will be reset back to its original value in between authentication requests.
@property (nonatomic, copy) NSString *userAgentForAuth
Declared In
SFOAuthCoordinator.h
additionalOAuthParameterKeys
An array of additional keys (NSString) to parse during OAuth
@property (nonatomic, strong) NSArray *additionalOAuthParameterKeys
Declared In
SFOAuthCoordinator.h
additionalTokenRefreshParams
A dictionary of additional parameters (key value pairs) to send during token refresh
@property (nonatomic, strong) NSDictionary *additionalTokenRefreshParams
Declared In
SFOAuthCoordinator.h
brandLoginPath
Brand Login Path.
The brand login path used for the authorize endpoint e.g. /brand in
https://community.force.com/services/oauth2/authorize/
@property (nonatomic, copy) NSString *brandLoginPath
Declared In
SFOAuthCoordinator.h
useBrowserAuth
Setup the coordinator to use ASWebAuthenticationSession for authentication.
@property (nonatomic, assign) BOOL useBrowserAuth
Declared In
SFOAuthCoordinator.h
useNativeAuth
Setup the coordinator to use an app provided native UI for authentication.
@property (nonatomic, assign) BOOL useNativeAuth
Declared In
SFOAuthCoordinator.h
Initialization
– initWithCredentials:
Initializes a new OAuth coordinator with the supplied credentials. This is the designated initializer.
- (id)initWithCredentials:(null_unspecified SFOAuthCredentials *)credentials
Parameters
credentials |
An instance of |
---|
Return Value
The initialized authentication coordinator.
Discussion
Warning: Although it is permissible to pass nil
for the credentials argument, the credentials propery
must not be nil
prior to calling the authenticate
method or an exception will be raised.
See Also
Declared In
SFOAuthCoordinator.h
Authentication control
– authenticate
Begins the authentication process.
- (void)authenticate
Exceptions
NSInternalInconsistencyException |
If called when the |
---|
Declared In
SFOAuthCoordinator.h
– authenticateWithCredentials:
Sets the credentials property and begins the authentication process. Simply a convenience method for:
coordinator.
credentials = theCredentials;
[coordinator authenticate];
- (void)authenticateWithCredentials:(SFOAuthCredentials *)credentials
Parameters
credentials |
The OAuth credentials used for authentication. |
---|
Exceptions
NSInternalInconsistencyException |
If called with a |
---|
Declared In
SFOAuthCoordinator.h
– isAuthenticating
Returns YES if the coordinator is in the process of authentication; otherwise NO.
- (BOOL)isAuthenticating
Declared In
SFOAuthCoordinator.h
– stopAuthentication
Stops the authentication process.
- (void)stopAuthentication
Declared In
SFOAuthCoordinator.h
– revokeAuthentication
Revokes the authentication credentials.
- (void)revokeAuthentication
Declared In
SFOAuthCoordinator.h
– handleAdvancedAuthenticationResponse:
Handle an advanced authentication response from the external browser, continuing any in-progress adavanced authentication flow.
- (BOOL)handleAdvancedAuthenticationResponse:(NSURL *)appUrlResponse
Parameters
appUrlResponse |
The URL response returned to the app from the external browser. |
---|
Return Value
YES if this is a valid URL response from advanced authentication that the coordinator should handle, NO otherwise.
Declared In
SFOAuthCoordinator.h
– beginIDPFlow:success:failure:
- (void)beginIDPFlow:(SFUserAccount *)user success:(void ( ^ ) ( void ))successBlock failure:(void ( ^ ) ( NSError *))failureBlock
Extension Methods
overrideWithFrontDoorBridgeUrl
For Salesforce Identity UI Bridge API support, an overriding front door bridge URL to use in place of the default initial URL.
@property (nonatomic, strong, nullable) NSURL *overrideWithFrontDoorBridgeUrl
Declared In
SFOAuthCoordinator+Internal.h
overrideWithCodeVerifier
For Salesforce Identity UI Bridge API support, the optional web server flow code verififer accompaning the front door bridge URL. This can only be used with overrideWithfrontDoorBridgeUrl
.
@property (nonatomic, strong, nullable) NSString *overrideWithCodeVerifier
Declared In
SFOAuthCoordinator+Internal.h
– updateCredentials:
UpdateCredentials and record changes to instanceUrl,accessToken,communityId
- (void)updateCredentials:(NSDictionary *)params
Parameters
params |
NV pairs received from token endpoint. |
---|
Declared In
SFOAuthCoordinator+Internal.h
– notifyDelegateOfFailure:authInfo:
Notify our delegate that we could not log in, and clear authenticating flag
- (void)notifyDelegateOfFailure:(NSError *)error authInfo:(SFOAuthInfo *)info
Declared In
SFOAuthCoordinator+Internal.h
– notifyDelegateOfSuccess:
Notify our delegate that login succeeded, and clear authenticating flag
- (void)notifyDelegateOfSuccess:(SFOAuthInfo *)authInfo
Declared In
SFOAuthCoordinator+Internal.h
– generateApprovalUrlString
Used for testing only.
- (NSString *)generateApprovalUrlString
Return Value
A String representing the prepared authorize url
Declared In
SFOAuthCoordinator+Internal.h