From 5331ad15ae1b9e38521d2f526858e56746ee4a52 Mon Sep 17 00:00:00 2001 From: SushilMallRC Date: Tue, 2 Jul 2024 00:23:16 +0530 Subject: [PATCH] disable auto token refreshment --- sdk/README.md | 11 +++++++++++ sdk/src/platform/Platform.ts | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/sdk/README.md b/sdk/README.md index 7e82ddb..539c55e 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -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) --- @@ -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). diff --git a/sdk/src/platform/Platform.ts b/sdk/src/platform/Platform.ts index a35c0f0..fca7f8f 100644 --- a/sdk/src/platform/Platform.ts +++ b/sdk/src/platform/Platform.ts @@ -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 { return this.send({method: 'GET', url, query, ...options}); }