SPiDClient Class Reference
| Inherits from | NSObject |
| Declared in | SPiDClient.h SPiDClient.m |
Overview
The main SDK class, all interaction with SPiD goes through this class
SPiDClient contains a singleton instance and all calls to SPiD should go through this instance.
Tasks
Properties
-
clientIDClient ID provided by SPiD
property -
serverClientIDClient ID to be used when generating a one time code. Defaults to
propertyclientID. -
clientSecretClient secret provided by SPiD
property -
signSecretSigning secret provided by SPiD
property -
appURLSchemeApp URL schema
property -
redirectURIRedirect URI
property -
serverURLURL to the SPiD server
property -
authorizationURLURL to use for web authorization with SPiD
property -
signupURLURL to use for web signup with SPiD
property -
forgotPasswordURLURL to use for web forgot password with SPiD
property -
logoutURLURL to use for logout with SPiD
property -
tokenURLURL to use for requesting access token from SPiD
property -
saveToKeychainSets if access token should be saved in keychain, default value is YES
property -
apiVersionSPiDThe API version that should be used, defaults to 2
property -
useMobileWebUse mobile web version for SPiD, default YES
property -
webViewInitialHTMLHTML string that will be show when WebView is loading
property -
accessTokenThe SPiD access token
property -
waitingRequestsQueue for waiting requests
property
Public Methods
-
+ sharedInstanceReturns the singleton instance of SPiDClient
-
+ setClientID:clientSecret:appURLScheme:serverURL:Configures the
SPiDClientand creates a singleton instance -
– browserRedirectAuthorizationWithCompletionHandler:Redirects to safari for authorization
-
– browserRedirectSignupWithCompletionHandler:Redirects to safari for signup
-
– browserRedirectForgotPasswordRedirects to safari for forgot password
-
– browserRedirectLogoutWithCompletionHandler:Redirects to safari for logout
-
– handleOpenURL:Handles URL redirects to the app
-
– logoutRequestWithCompletionHandler:Logout from SPiD
-
– hasTokenExpiredChecks if the access token has expired
-
– tokenExpiresAtReturns the time when access token expires
-
– currentUserIDReturns the user ID for the current user
-
– isAuthorizedReturns YES if
SPiDClienthas a access token -
– isClientTokenReturns YES if
SPiDClienthas a client access token
Request wrappers
-
– getOneTimeCodeRequestWithCompletionHandler:Requests a one time code to be used server side. *
-
– getMeRequestWithCompletionHandler:Requests the currently logged in user’s object. Note that the user session does not last as long as the access token, therefor the me request should only be used right after the app has received a access token. The user id should then be saved and used with the
getUserRequestWithID:andCompletionHandler -
– getUserRequestWithID:completionHandler:Requests the userinformation for the specified userID
-
– getCurrentUserRequestWithCompletionHandler:Requests the userinformation for the current user
-
– getUserLoginsRequestWithUserID:completionHandler:Request all login attempts for a specific client
-
– authorizationURLWithQueryGenerates the authorization url with query parameters
-
– signupURLWithQueryGenerates the signup url with query parameters
-
– forgotPasswordURLWithQueryGenerates the forgot password url with query parameters
-
– logoutURLWithQueryGenerates the logout url with query parameters
Private methods
-
– initInitializes the
SPiDClientshould not be called directly -
– doHandleOpenURL:Helper method
-
– getAuthorizationQueryBuilds authorization query
-
– getLogoutQueryBuilds logout query
-
– refreshAccessTokenAndRerunRequest:Tries to refresh access token and rerun waiting requests
-
– clearAuthorizationRequestClears current authorization request and waiting requests
-
– authorizationComplete: -
– logoutCompleteRuns after logout has been completed, should not be called directly
Properties
accessToken
The SPiD access token
@property (strong, nonatomic) SPiDAccessToken *accessTokenDeclared In
SPiDClient.hapiVersionSPiD
The API version that should be used, defaults to 2
@property (strong, nonatomic) NSString *apiVersionSPiDDeclared In
SPiDClient.happURLScheme
App URL schema
@property (strong, nonatomic) NSString *appURLSchemeDiscussion
This is used for generating the redirect URI needed for switching back from safari to app
Declared In
SPiDClient.hauthorizationURL
URL to use for web authorization with SPiD
@property (strong, nonatomic) NSURL *authorizationURLDiscussion
This URL is normally generated using the serverURL/auth/login
Declared In
SPiDClient.hclientID
Client ID provided by SPiD
@property (strong, nonatomic) NSString *clientIDDeclared In
SPiDClient.hclientSecret
Client secret provided by SPiD
@property (strong, nonatomic) NSString *clientSecretDeclared In
SPiDClient.hforgotPasswordURL
URL to use for web forgot password with SPiD
@property (strong, nonatomic) NSURL *forgotPasswordURLDiscussion
This URL is normally generated using the serverURL/auth/forgotpassword
Declared In
SPiDClient.hlogoutURL
URL to use for logout with SPiD
@property (nonatomic, strong) NSURL *logoutURLDiscussion
This URL is normally generated using the serverURL/logout
Declared In
SPiDClient.hredirectURI
Redirect URI
@property (strong, nonatomic) NSURL *redirectURIDiscussion
This is normally generated by the SDK using the appURLSchema://SPiD
Declared In
SPiDClient.hsaveToKeychain
Sets if access token should be saved in keychain, default value is YES
@property (nonatomic) BOOL saveToKeychainDeclared In
SPiDClient.hserverClientID
Client ID to be used when generating a one time code. Defaults to clientID.
@property (strong, nonatomic) NSString *serverClientIDDeclared In
SPiDClient.hserverURL
URL to the SPiD server
@property (strong, nonatomic) NSURL *serverURLDeclared In
SPiDClient.hsignSecret
Signing secret provided by SPiD
@property (strong, nonatomic) NSString *signSecretDeclared In
SPiDClient.hsignupURL
URL to use for web signup with SPiD
@property (strong, nonatomic) NSURL *signupURLDiscussion
This URL is normally generated using the serverURL/auth/signup
Declared In
SPiDClient.htokenURL
URL to use for requesting access token from SPiD
@property (strong, nonatomic) NSURL *tokenURLDiscussion
This URL is normally generated using the serverURL/oauth/token
Declared In
SPiDClient.huseMobileWeb
Use mobile web version for SPiD, default YES
@property (nonatomic) BOOL useMobileWebDeclared In
SPiDClient.hClass Methods
setClientID:clientSecret:appURLScheme:serverURL:
Configures the SPiDClient and creates a singleton instance
+ (void)setClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret appURLScheme:(NSString *)appURLSchema serverURL:(NSURL *)serverURLParameters
- clientID
The client ID provided by SPiD
- clientSecret
The client secret provided by SPiD
- appURLSchema
The url schema for the app (eg spidtest://)
- serverURL
The url to SPiD
Declared In
SPiDClient.hsharedInstance
Returns the singleton instance of SPiDClient
+ (SPiDClient *)sharedInstanceReturn Value
Returns singleton instance
Discussion
The SPiDClient needs to be configured first with setClientID:clientSecret:appURLScheme:serverURL:
Declared In
SPiDClient.hInstance Methods
authorizationURLWithQuery
Generates the authorization url with query parameters
- (NSURL *)authorizationURLWithQueryReturn Value
The url with query parameters
Declared In
SPiDClient.hbrowserRedirectAuthorizationWithCompletionHandler:
Redirects to safari for authorization
- (void)browserRedirectAuthorizationWithCompletionHandler:(void ( ^ ) ( NSError *))completionHandlerParameters
- completionHandler
Called on login completion or error
Declared In
SPiDClient.hbrowserRedirectForgotPassword
Redirects to safari for forgot password
- (void)browserRedirectForgotPasswordDeclared In
SPiDClient.hbrowserRedirectLogoutWithCompletionHandler:
Redirects to safari for logout
- (void)browserRedirectLogoutWithCompletionHandler:(void ( ^ ) ( NSError *))completionHandlerParameters
- completionHandler
Called on logout completion or error
Declared In
SPiDClient.hbrowserRedirectSignupWithCompletionHandler:
Redirects to safari for signup
- (void)browserRedirectSignupWithCompletionHandler:(void ( ^ ) ( NSError *))completionHandlerParameters
- completionHandler
Called on signup completion or error
Declared In
SPiDClient.hclearAuthorizationRequest
Clears current authorization request and waiting requests
- (void)clearAuthorizationRequestDeclared In
SPiDClient.mcurrentUserID
Returns the user ID for the current user
- (NSString *)currentUserIDReturn Value
Returns user ID
Declared In
SPiDClient.hdoHandleOpenURL:
Helper method
- (BOOL)doHandleOpenURL:(NSURL *)urlParameters
- url
The url to handle
Declared In
SPiDClient.mforgotPasswordURLWithQuery
Generates the forgot password url with query parameters
- (NSURL *)forgotPasswordURLWithQueryReturn Value
The url with query parameters
Declared In
SPiDClient.hgetAuthorizationQuery
Builds authorization query
- (NSString *)getAuthorizationQueryReturn Value
The authorization query parameters
Declared In
SPiDClient.mgetCurrentUserRequestWithCompletionHandler:
Requests the userinformation for the current user
- (void)getCurrentUserRequestWithCompletionHandler:(void ( ^ ) ( SPiDResponse *))completionHandlerParameters
- completionHandler
Called on request completion or error
Discussion
For information about the return object see: http://www.schibstedpayment.no/docs/doku.php?id=wiki:user_api
Warning: Requires that the user is authorized with SPiD
See Also
Declared In
SPiDClient.hgetLogoutQuery
Builds logout query
- (NSString *)getLogoutQueryReturn Value
The logout query parameters
Declared In
SPiDClient.mgetMeRequestWithCompletionHandler:
Requests the currently logged in user’s object. Note that the user session does not last as long as the access token, therefor the me request should only be used right after the app has received a access token. The user id should then be saved and used with the getUserRequestWithID:andCompletionHandler
- (void)getMeRequestWithCompletionHandler:(void ( ^ ) ( SPiDResponse *response ))completionHandlerParameters
- completionHandler
Called on request completion or error
Discussion
For information about the return object see: http://www.schibstedpayment.no/docs/doku.php?id=wiki:user_api
Warning: Requires that the user is authorized with SPiD
See Also
Declared In
SPiDClient.hgetOneTimeCodeRequestWithCompletionHandler:
Requests a one time code to be used server side. *
- (void)getOneTimeCodeRequestWithCompletionHandler:(void ( ^ ) ( SPiDResponse *))completionHandlerParameters
- completionHandler
Called on request completion or error
Discussion
Note: The code is generated using the server client id and not the applications client id.
Warning: Requires that the user is authorized with SPiD
Declared In
SPiDClient.hgetUserLoginsRequestWithUserID:completionHandler:
Request all login attempts for a specific client
- (void)getUserLoginsRequestWithUserID:(NSString *)userID completionHandler:(void ( ^ ) ( SPiDResponse *response ))completionHandlerParameters
- userID
The userID that logins should be fetched for
- completionHandler
Called on request completion or error
Discussion
For information about the return object see: http://www.schibstedpayment.no/docs/doku.php?id=wiki:login_api
Warning: Requires that the user is authorized with SPiD
See Also
Declared In
SPiDClient.hgetUserRequestWithID:completionHandler:
Requests the userinformation for the specified userID
- (void)getUserRequestWithID:(NSString *)userID completionHandler:(void ( ^ ) ( SPiDResponse *response ))completionHandlerParameters
- userID
ID for the selected user
- completionHandler
Called on request completion or error
Discussion
For information about the return object see: http://www.schibstedpayment.no/docs/doku.php?id=wiki:user_api
Warning: Requires that the user is authorized with SPiD
See Also
Declared In
SPiDClient.hhandleOpenURL:
Handles URL redirects to the app
- (BOOL)handleOpenURL:(NSURL *)urlParameters
- url
Input URL
Return Value
Returns YES if URL was handled by SPiDClient
Declared In
SPiDClient.hhasTokenExpired
Checks if the access token has expired
- (BOOL)hasTokenExpiredReturn Value
Returns YES if access token has expired
Declared In
SPiDClient.hinit
Initializes the SPiDClient should not be called directly
- (id)initDiscussion
Tries to load the access token from the keychain
Declared In
SPiDClient.misAuthorized
Returns YES if SPiDClient has a access token
- (BOOL)isAuthorizedReturn Value
Returns YES if SPiDClient is authorized
Declared In
SPiDClient.hisClientToken
Returns YES if SPiDClient has a client access token
- (BOOL)isClientTokenReturn Value
Returns YES if SPiDClient has a client access token
Declared In
SPiDClient.hlogoutComplete
Runs after logout has been completed, should not be called directly
- (void)logoutCompleteDeclared In
SPiDClient.mlogoutRequestWithCompletionHandler:
Logout from SPiD
- (SPiDRequest *)logoutRequestWithCompletionHandler:(void ( ^ ) ( NSError *response ))completionHandlerParameters
- completionHandler
Called on logout completion or error
Discussion
This requires that the app has obtained a access token. Redirects to safari to logout from SPiD and remove cookie. Also removes access token from keychain
Warning: SPiDClient has to be logged in before this call. The receiver must also check if a error was returned to the _completionHandler.
See Also
Declared In
SPiDClient.hlogoutURLWithQuery
Generates the logout url with query parameters
- (NSURL *)logoutURLWithQueryReturn Value
The url with query parameters
Declared In
SPiDClient.hrefreshAccessTokenAndRerunRequest:
Tries to refresh access token and rerun waiting requests
- (void)refreshAccessTokenAndRerunRequest:(SPiDRequest *)requestParameters
- request
The request to retry after a new access token has been acquired
Declared In
SPiDClient.m