Access Token | |
---|---|
Access Token TTL | |
Refresh Token | |
Refresh Token TTL | |
Scope |
To access a user's RingCentral data, the app needs to request and receive OAuth 2.0 access token to access that data. In this demo, clicking the will allow the user to enter their username, extension and password which the app then uses to call the authorize() method as shown below to receive an access token / refresh token pair.
platform.authorize({
username: username,
extension: extension,
password: password
}).then(function(response) {
// run success code
}).catch(function(e) {
//run exception code
});
Using the SDK's logout functionality will end revoke the current token. The button will exercise the platform.logout() method to end the user's authorization grant.
platform.logout().then(...).catch(...);
During standard usage, token refresh will be handled automatically by the JavaScript SDK. By default, OAuth 2.0 values for expires_in and refresh_token_expires_in are set and the SDK will automatically perform a refresh with the access token has expired but the refresh token is still valid. To manually execute a refresh, you can use the following code.
platform.refresh().then(...).catch(...);