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

Public Methods

Request wrappers

Private methods

Properties

accessToken

The SPiD access token

@property (strong, nonatomic) SPiDAccessToken *accessToken

Declared In

SPiDClient.h

apiVersionSPiD

The API version that should be used, defaults to 2

@property (strong, nonatomic) NSString *apiVersionSPiD

Declared In

SPiDClient.h

appURLScheme

App URL schema

@property (strong, nonatomic) NSString *appURLScheme

Discussion

This is used for generating the redirect URI needed for switching back from safari to app

Declared In

SPiDClient.h

authorizationURL

URL to use for web authorization with SPiD

@property (strong, nonatomic) NSURL *authorizationURL

Discussion

This URL is normally generated using the serverURL/auth/login

Declared In

SPiDClient.h

clientID

Client ID provided by SPiD

@property (strong, nonatomic) NSString *clientID

Declared In

SPiDClient.h

clientSecret

Client secret provided by SPiD

@property (strong, nonatomic) NSString *clientSecret

Declared In

SPiDClient.h

forgotPasswordURL

URL to use for web forgot password with SPiD

@property (strong, nonatomic) NSURL *forgotPasswordURL

Discussion

This URL is normally generated using the serverURL/auth/forgotpassword

Declared In

SPiDClient.h

logoutURL

URL to use for logout with SPiD

@property (nonatomic, strong) NSURL *logoutURL

Discussion

This URL is normally generated using the serverURL/logout

Declared In

SPiDClient.h

redirectURI

Redirect URI

@property (strong, nonatomic) NSURL *redirectURI

Discussion

This is normally generated by the SDK using the appURLSchema://SPiD

Declared In

SPiDClient.h

saveToKeychain

Sets if access token should be saved in keychain, default value is YES

@property (nonatomic) BOOL saveToKeychain

Declared In

SPiDClient.h

serverClientID

Client ID to be used when generating a one time code. Defaults to clientID.

@property (strong, nonatomic) NSString *serverClientID

Declared In

SPiDClient.h

serverURL

URL to the SPiD server

@property (strong, nonatomic) NSURL *serverURL

Declared In

SPiDClient.h

signSecret

Signing secret provided by SPiD

@property (strong, nonatomic) NSString *signSecret

Declared In

SPiDClient.h

signupURL

URL to use for web signup with SPiD

@property (strong, nonatomic) NSURL *signupURL

Discussion

This URL is normally generated using the serverURL/auth/signup

Declared In

SPiDClient.h

tokenURL

URL to use for requesting access token from SPiD

@property (strong, nonatomic) NSURL *tokenURL

Discussion

This URL is normally generated using the serverURL/oauth/token

Declared In

SPiDClient.h

useMobileWeb

Use mobile web version for SPiD, default YES

@property (nonatomic) BOOL useMobileWeb

Declared In

SPiDClient.h

waitingRequests

Queue for waiting requests

@property (nonatomic, strong) NSMutableArray *waitingRequests

Declared In

SPiDClient.h

webViewInitialHTML

HTML string that will be show when WebView is loading

@property (strong, nonatomic) NSString *webViewInitialHTML

Declared In

SPiDClient.h

Class 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 *)serverURL

Parameters

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.h

sharedInstance

Returns the singleton instance of SPiDClient

+ (SPiDClient *)sharedInstance

Return Value

Returns singleton instance

Discussion

The SPiDClient needs to be configured first with setClientID:clientSecret:appURLScheme:serverURL:

Declared In

SPiDClient.h

Instance Methods

authorizationComplete:

- (void)authorizationComplete:(SPiDAccessToken *)token

authorizationURLWithQuery

Generates the authorization url with query parameters

- (NSURL *)authorizationURLWithQuery

Return Value

The url with query parameters

Declared In

SPiDClient.h

browserRedirectAuthorizationWithCompletionHandler:

Redirects to safari for authorization

- (void)browserRedirectAuthorizationWithCompletionHandler:(void ( ^ ) ( NSError *))completionHandler

Parameters

completionHandler

Called on login completion or error

Declared In

SPiDClient.h

browserRedirectForgotPassword

Redirects to safari for forgot password

- (void)browserRedirectForgotPassword

Declared In

SPiDClient.h

browserRedirectLogoutWithCompletionHandler:

Redirects to safari for logout

- (void)browserRedirectLogoutWithCompletionHandler:(void ( ^ ) ( NSError *))completionHandler

Parameters

completionHandler

Called on logout completion or error

Declared In

SPiDClient.h

browserRedirectSignupWithCompletionHandler:

Redirects to safari for signup

- (void)browserRedirectSignupWithCompletionHandler:(void ( ^ ) ( NSError *))completionHandler

Parameters

completionHandler

Called on signup completion or error

Declared In

SPiDClient.h

clearAuthorizationRequest

Clears current authorization request and waiting requests

- (void)clearAuthorizationRequest

Declared In

SPiDClient.m

currentUserID

Returns the user ID for the current user

- (NSString *)currentUserID

Return Value

Returns user ID

Declared In

SPiDClient.h

doHandleOpenURL:

Helper method

- (BOOL)doHandleOpenURL:(NSURL *)url

Parameters

url

The url to handle

Declared In

SPiDClient.m

forgotPasswordURLWithQuery

Generates the forgot password url with query parameters

- (NSURL *)forgotPasswordURLWithQuery

Return Value

The url with query parameters

Declared In

SPiDClient.h

getAuthorizationQuery

Builds authorization query

- (NSString *)getAuthorizationQuery

Return Value

The authorization query parameters

Declared In

SPiDClient.m

getCurrentUserRequestWithCompletionHandler:

Requests the userinformation for the current user

- (void)getCurrentUserRequestWithCompletionHandler:(void ( ^ ) ( SPiDResponse *))completionHandler

Parameters

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.h

getLogoutQuery

Builds logout query

- (NSString *)getLogoutQuery

Return Value

The logout query parameters

Declared In

SPiDClient.m

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

- (void)getMeRequestWithCompletionHandler:(void ( ^ ) ( SPiDResponse *response ))completionHandler

Parameters

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.h

getOneTimeCodeRequestWithCompletionHandler:

Requests a one time code to be used server side. *

- (void)getOneTimeCodeRequestWithCompletionHandler:(void ( ^ ) ( SPiDResponse *))completionHandler

Parameters

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.h

getUserLoginsRequestWithUserID:completionHandler:

Request all login attempts for a specific client

- (void)getUserLoginsRequestWithUserID:(NSString *)userID completionHandler:(void ( ^ ) ( SPiDResponse *response ))completionHandler

Parameters

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.h

getUserRequestWithID:completionHandler:

Requests the userinformation for the specified userID

- (void)getUserRequestWithID:(NSString *)userID completionHandler:(void ( ^ ) ( SPiDResponse *response ))completionHandler

Parameters

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.h

handleOpenURL:

Handles URL redirects to the app

- (BOOL)handleOpenURL:(NSURL *)url

Parameters

url

Input URL

Return Value

Returns YES if URL was handled by SPiDClient

Declared In

SPiDClient.h

hasTokenExpired

Checks if the access token has expired

- (BOOL)hasTokenExpired

Return Value

Returns YES if access token has expired

Declared In

SPiDClient.h

init

Initializes the SPiDClient should not be called directly

- (id)init

Discussion

Tries to load the access token from the keychain

Declared In

SPiDClient.m

isAuthorized

Returns YES if SPiDClient has a access token

- (BOOL)isAuthorized

Return Value

Returns YES if SPiDClient is authorized

Declared In

SPiDClient.h

isClientToken

Returns YES if SPiDClient has a client access token

- (BOOL)isClientToken

Return Value

Returns YES if SPiDClient has a client access token

Declared In

SPiDClient.h

logoutComplete

Runs after logout has been completed, should not be called directly

- (void)logoutComplete

Declared In

SPiDClient.m

logoutRequestWithCompletionHandler:

Logout from SPiD

- (SPiDRequest *)logoutRequestWithCompletionHandler:(void ( ^ ) ( NSError *response ))completionHandler

Parameters

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.h

logoutURLWithQuery

Generates the logout url with query parameters

- (NSURL *)logoutURLWithQuery

Return Value

The url with query parameters

Declared In

SPiDClient.h

refreshAccessTokenAndRerunRequest:

Tries to refresh access token and rerun waiting requests

- (void)refreshAccessTokenAndRerunRequest:(SPiDRequest *)request

Parameters

request

The request to retry after a new access token has been acquired

Declared In

SPiDClient.m

signupURLWithQuery

Generates the signup url with query parameters

- (NSURL *)signupURLWithQuery

Return Value

The url with query parameters

Declared In

SPiDClient.h

tokenExpiresAt

Returns the time when access token expires

- (NSDate *)tokenExpiresAt

Return Value

Returns the date when the access token expires

Declared In

SPiDClient.h