OpenPass SDK for Roku reference
For background information on the OpenPass service, and general information on implementation, see Getting started with OpenPass.
This SDK uses the OpenPassManager.brs method to manage OpenPass user sign-in and device token retrieval. It creates a central hub, the OpenPass manager, for these tasks. To initialize this manager within your application, call the Init function when creating your application.
States
The manager has the following states:
| Number |
State |
Description |
0 |
NotInitialized |
The manager is created but not initialized. |
1 |
Loading |
The manager is loading the initial state or starting the sign-in process. |
2 |
SignedIn |
The user is successfully authenticated and considered to be signed-in. |
3 |
SignedOut |
The user is not authenticated, or has signed out. |
4 |
Polling |
The sign-in process is in progress, and is waiting for the user to authenticate. |
5 |
Error |
An error occurred. More information can be found in the thrown exception or logs. |
Parameters
The manager includes the following parameters:
| Parameter |
Attribute Name |
Data Type |
Required? |
Description |
| Client ID |
clientId |
string |
Yes |
The client ID provided by OpenPass for the application. |
| User state handler callback |
userStateHandlerCallbackParam |
associative array |
Yes |
A user-defined method used to signify a state change in the sign-in flow. This method takes two parameters:_state(integer): The current state of the manager. This can be one of the states in the states enum._data(object): A data set that provides more information about the state change. Possible values include:message(string): An message with more information about the state change.error_message(string): A message describing the error state.warning_message(string): A message describing the warning state.device_token_success(object): A data set that provides more information about a successfully created device token. The information includes:decoded_id_token: The decoded ID token, which contains details of the user's identity, including their email address.id_token: The raw ID token string (JWT), which contains details of the user's identity, including their email address, first (given) name, and last name (surname).access_token: The access token string, which can be used for Bearer authorization against APIs.expires_in: Indicates the time in seconds until the access token expires.refresh_token: The refresh token issued by the OpenPass authorization server to enable the relying party, such as an app or website, to refresh an access token.refresh_token_expires_in: Indicates the time in seconds until the refresh token expires.token_type: The token type, which is always Bearer.
authorize_device_success(object): The authorize-device data returned from the OpenPass API. The following is used to start the polling process:client_id(string): The client ID provided by OpenPass for the application.device_code(string): The device code used for polling the device-token endpoint to retrieve the access token.user_code(string): A user-friendly code typically displayed on the device for the user to register their device.verification_uri(string): The verification URI for authorizing the device by entering the user code.verification_uri_complete(string): The verification URI containing the user code as an HTTP query parameter and typically displayed on the device as part of the QR code.interval(integer): The time in seconds between polling requests by the device for a new device token at the endpoint.expires_in(integer): The maximum time in seconds for the device to poll for the registration result, and for the user to complete device registration.
|
| Optional parameters |
optionalParams |
associative array |
No |
A set of options for configuring the manager, including the following:enable_logging(boolean): Enable logging to a file. The default value is false.enable_testing(boolean): Enable testing mode. The default value is false.
|