Inherits from NSObject
Declared in OlapicOAuthMethod.h

Overview

The base interface for the OAuth connections. The subclass should be able to get, validate and manage the tokens

Properties

OAuthClient

The AFNetworking ‘plugin’ that makes the connections to the OAuth server

@property (nonatomic, strong) OlapicAFOAuth2Client *OAuthClient

Declared In

OlapicOAuthMethod.h

keychain

The object in charge of saving the credentials on the Keychain

@property (nonatomic, strong) KeychainItemWrapper *keychain

Declared In

OlapicOAuthMethod.h

Instance Methods

canReuseToken

Check if a saved token can be reused. If it returns true, it can be retrieved using getSavedToken

- (BOOL)canReuseToken

Return Value

If the token can be reused or not

Availability

v1.0

Declared In

OlapicOAuthMethod.h

clearCache

Clear any information saved on the app settings

- (void)clearCache

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getDeviceIdentifier

Get the device identifier saved on the app settings

- (NSString *)getDeviceIdentifier

Return Value

The identifier

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getKeychain

Get the Keychain object to save and read credentials

- (KeychainItemWrapper *)getKeychain

Return Value

The Keychain object

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getOAuthClient

Get the AFNetworking OAuth ‘plugin’ instance

- (OlapicAFOAuth2Client *)getOAuthClient

Return Value

The OAuth client

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getOAuthURL

Get the OAuth server URL

- (NSString *)getOAuthURL

Return Value

The OAuth server URL

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getSavedToken

Retrieve a saved token from the app settings

- (NSString *)getSavedToken

Return Value

The saved token

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getScopes

Once connected, this method can be used to retrieve the list of scopes associated to the token

- (NSArray *)getScopes

Return Value

The list of scopes

Availability

v1.0

Declared In

OlapicOAuthMethod.h

getSettingsKey

The key used by the class to saved information into the app settings. The subclass should extend this method with its own key.

- (NSString *)getSettingsKey

Return Value

The key

Availability

v1.0

Declared In

OlapicOAuthMethod.h

hasScope:

An easy way to check if the connected token has a specific scope

- (BOOL)hasScope:(NSString *)scope

Parameters

scope

The scope you want to verify

Return Value

Whether the scope is preset or not

Availability

v1.0

Declared In

OlapicOAuthMethod.h

restoreScopes

Restore the saved token scopes into this object

- (void)restoreScopes

Availability

v1.0

Declared In

OlapicOAuthMethod.h

saveCredentials:

Save a set of credentials provided by the AFNetworking ‘plugin’

- (void)saveCredentials:(OlapicAFOAuthCredential *)credentials

Parameters

credentials

The credentials object

Availability

v1.0

Declared In

OlapicOAuthMethod.h

setOAuthURL:

The SDK singleton will use this method to set the OAuth server URL

- (void)setOAuthURL:(NSString *)URL

Parameters

URL

The OAuth server URL

Availability

v1.0

Declared In

OlapicOAuthMethod.h

setup

This is the method the subclass will use to create an instance of the AFNetworking ‘plugin’ and do extra setup

- (void)setup

Availability

v1.0

Declared In

OlapicOAuthMethod.h

validateRequest:onFailure:

This is the method the subclass will use to validate the existence and the expiration date of a token, before doing any request

- (void)validateRequest:(void ( ^ ) ( NSString *token ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

success

The callback method to be called after a valid token is retrieved/created

failure

The callback method to be called if the client has to connect to the server, and the connection fails

Availability

v1.0

Declared In

OlapicOAuthMethod.h