Skip to content

Commit

Permalink
Merge pull request #261 from ringcentral/RCLABS-828
Browse files Browse the repository at this point in the history
disable auto token refreshment
  • Loading branch information
SushilMallRC authored Jul 1, 2024
2 parents 0cc180a + 5331ad1 commit 49c9942
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Fax](#fax)
- [Page visibility](#page-visibility)
- [Tracking network Requests And Responses](#tracking-network-requests-and-responses)
- [Disable Auto Token refreshment](#disable-auto-token-refreshment)

---

Expand Down Expand Up @@ -904,3 +905,13 @@ client.on(client.events.beforeRequest, function (apiResponse) {}); // apiRespons
client.on(client.events.requestSuccess, function (apiResponse) {});
client.on(client.events.requestError, function (apiError) {});
```
# Disable Auto Token refreshment
To disable the automatic token refresh feature, you can include the following code snippet in your application: [Demo](https://github.com/tylerlong/rc-js-sdk-no-auto-refresh-token-demo)
```
platform.ensureLoggedIn = async () => null;
```
This code effectively overrides the default token refresh mechanism, preventing the platform from automatically renewing the authentication token.
For a detailed explanation and further information, please refer to this article: [Disable Auto Token Refreshment](https://medium.com/@tylerlong/how-to-disable-auto-token-refreshment-for-ringcentral-javascript-sdk-461d7982ed35).
7 changes: 7 additions & 0 deletions sdk/src/platform/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,13 @@ export default class Platform extends EventEmitter {
return this.sendRequest(this._client.createRequest(options), options);
}

/**
* These methods refresh access token automatically if it's expired.
* If you want to handle it yourself and disable auto refresh, place below code snippet in your code.
* platform.ensureLoggedIn = async () => null;
* For more details, please refer to https://medium.com/ringcentral-developers/how-to-disable-auto-token-refreshment-for-ringcentral-javascript-sdk-461d7982ed35
* You can also follow demo https://github.com/tylerlong/rc-js-sdk-no-auto-refresh-token-demo
*/
public async get(url, query?, options?: SendOptions): Promise<Response> {
return this.send({method: 'GET', url, query, ...options});
}
Expand Down

0 comments on commit 49c9942

Please sign in to comment.