authorize

abstract fun authorize(token: String, locationId: String, callback: Callback<AuthorizeResult>): CallbackReference

Asynchronously authorizes Mobile Payments SDK with an OAuth Access Token and Location ID. Applications must authorize Mobile Payments SDK before performing any other operations.

If authorization completes successfully, the callback will be called with a AuthorizedLocation object containing information about user's location. In case of failure, error description would contain an AuthorizeErrorCode.

This method must be called from the main thread. It should always be given an authorization token and a location identifier.

Return

a CallbackReference handle to remove the callback later.

Parameters

token

An authorization token. Preferably an OAuth token created via the OAuth API, but it is possible to use a Personal Access Token instead. Best practice is generally to store tokens in server-side storage, refreshing and maintaining them there, and to send the token from that secure storage to the client application and to this API as part of a user login or registration process in your app.

locationId

The identifier of the location which will be associated with payments processed via the SDK.

callback

Adds a callback to handle the result of an authorization attempt. The callback is executed on the main thread. It is suggested to rely on setAuthorizationStateChangedCallback instead, however, as deauthorization can happen at any time due to token expiration or revocation. If a callback has already been provided via setAuthorizationStateChangedCallback and the authorization state changes during a call to this method, both this argument and the registered callback will be called.