UPPlatform Class Reference
Inherits from | NSObject |
Declared in | UPPlatform.h UPPlatform.m |
Overview
The base platform object, which manages the current session, authentication, and HTTP requests.
Tasks
-
currentSession
property -
redirectURI
property -
enableNetworkLogging
property -
+ sharedPlatform
-
+ basePlatformURL
-
+ currentPlatformVersion
-
– validateSessionWithCompletion:
-
– refreshAccessTokenWithClientID:clientSecret:completion:
-
– startSessionWithClientID:clientSecret:webView:completion:
-
– startSessionWithClientID:clientSecret:webView:authScope:completion:
-
– startSessionWithClientID:clientSecret:completion:
-
– startSessionWithClientID:clientSecret:authScope:completion:
-
– startSessionWithClientID:clientSecret:authScope:redirectURI:completion:
-
– endCurrentSession
-
– sendRequest:completion:
Properties
currentSession
The current session, if active. Will be nil if the user has not authenticated.
@property (nonatomic, readonly) UPSession *currentSession
Discussion
The current session, if active. Will be nil if the user has not authenticated.
Declared In
UPPlatform.h
enableNetworkLogging
Flag to enable extra network logging. Setting this to YES will log all HTTP requests and responses sent via UPPlatform.
@property (nonatomic, assign) BOOL enableNetworkLogging
Discussion
Flag to enable extra network logging. Setting this to YES will log all HTTP requests and responses sent via UPPlatform.
Declared In
UPPlatform.h
Class Methods
basePlatformURL
The base URL for the platform.
+ (NSString *)basePlatformURL
Discussion
The base URL for the platform.
Declared In
UPPlatform.h
Instance Methods
endCurrentSession
Ends the current session, clearing the session and access token.
- (void)endCurrentSession
Discussion
Ends the current session, clearing the session and access token.
Declared In
UPPlatform.h
refreshAccessTokenWithClientID:clientSecret:completion:
Refreshes the current access token.
- (void)refreshAccessTokenWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret completion:(UPPlatformSessionCompletion)completion
Discussion
Refreshes the current access token.
Declared In
UPPlatform.h
sendRequest:completion:
Sends an HTTP request, setting appropriate authentication headers based on the current session.
- (void)sendRequest:(UPURLRequest *)request completion:(UPPlatformRequestCompletion)completion
Parameters
- request
The request to send.
- completion
The request completion block after receiving a response or error.
Discussion
Sends an HTTP request, setting appropriate authentication headers based on the current session.
Declared In
UPPlatform.h
startSessionWithClientID:clientSecret:authScope:completion:
Starts a user’s session.
- (void)startSessionWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret authScope:(UPPlatformAuthScope)authScope completion:(UPPlatformSessionCompletion)completion
Parameters
- clientID
The client ID provided during application signup.
- clientSecret
The client secret provided during application signup.
- authScope
Options to request specific auth scopes during authentication. Defaults to UPPlatformAuthScopeBasicRead.
- completion
The session completion block.
Discussion
Starts a user’s session.
This will present a UIWebView to perform the OAuth authentication flow, taking care of getting the access token for HTTP requests.
Declared In
UPPlatform.h
startSessionWithClientID:clientSecret:authScope:redirectURI:completion:
Starts a user’s session.
- (void)startSessionWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret authScope:(UPPlatformAuthScope)authScope redirectURI:(NSString *)redirectURI completion:(UPPlatformSessionCompletion)completion
Parameters
- clientID
The client ID provided during application signup.
- clientSecret
The client secret provided during application signup.
- authScope
Options to request specific auth scopes during authentication. Defaults to UPPlatformAuthScopeBasicRead.
- redirectURI
An alternate redirect URI used during authentication. This is not common.
- completion
The session completion block.
Discussion
Starts a user’s session.
This will present a UIWebView to perform the OAuth authentication flow, taking care of getting the access token for HTTP requests.
Declared In
UPPlatform.h
startSessionWithClientID:clientSecret:completion:
Starts a user’s session.
- (void)startSessionWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret completion:(UPPlatformSessionCompletion)completion
Parameters
- clientID
The client ID provided during application signup.
- clientSecret
The client secret provided during application signup.
- completion
The session completion block.
Discussion
Starts a user’s session.
This will present a UIWebView to perform the OAuth authentication flow, taking care of getting the access token for HTTP requests.
Declared In
UPPlatform.h
startSessionWithClientID:clientSecret:webView:authScope:completion:
Starts a user’s session.
- (void)startSessionWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret webView:(WebView *)webView authScope:(UPPlatformAuthScope)authScope completion:(UPPlatformSessionCompletion)completion
Parameters
- clientID
The client ID provided during application signup.
- clientSecret
The client secret provided during application signup.
- webView
An existing WebView to perform authentication. Will create a new window with a single WebView if nil.
- authScope
Options to request specific auth scopes during authentication. Defaults to UPPlatformAuthScopeBasicRead.
- completion
The session completion block.
Discussion
Starts a user’s session.
This will present a WebView to perform the OAuth authentication flow, taking care of getting access token for HTTP requests. An existing WebView can be provided, or one will be created in a new window if nil is provided.
Declared In
UPPlatform.h
startSessionWithClientID:clientSecret:webView:completion:
Starts a user’s session.
- (void)startSessionWithClientID:(NSString *)clientID clientSecret:(NSString *)clientSecret webView:(WebView *)webView completion:(UPPlatformSessionCompletion)completion
Parameters
- clientID
The client ID provided during application signup.
- clientSecret
The client secret provided during application signup.
- webView
An existing WebView to perform authentication. Will create a new window with a single WebView if nil.
- completion
The session completion block.
Discussion
Starts a user’s session.
This will present a WebView to perform the OAuth authentication flow, taking care of getting access token for HTTP requests. An existing WebView can be provided, or one will be created in a new window if nil is provided.
Declared In
UPPlatform.h
validateSessionWithCompletion:
Validates the current session.
- (void)validateSessionWithCompletion:(UPPlatformSessionCompletion)completion
Parameters
- completion
The session completion block. If the session object passed to the completion block is not nil, the session is valid and API requests can be made.
Discussion
Validates the current session.
This method is useful in order to prevent any API requests from unexpectedly returning a 401 Unauthorized response when the user’s access token is not valid.
Declared In
UPPlatform.h