From bfb0dfa66492ecc94162c256fb945e8739186f0a Mon Sep 17 00:00:00 2001 From: mayuran-deriv <129507167+mayuran-deriv@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:44:31 +0400 Subject: [PATCH] [BOT] mayuran/FEQ-2478/TrackJS Dbot - 400 : POST https://oauth2.googleapis.com/revoke (#17489) * fix: expired token 403 issue * fix: signout on 403 issue --- .../src/stores/google-drive-store.ts | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/bot-web-ui/src/stores/google-drive-store.ts b/packages/bot-web-ui/src/stores/google-drive-store.ts index 49f7edb44d99..a23d9104bc0b 100644 --- a/packages/bot-web-ui/src/stores/google-drive-store.ts +++ b/packages/bot-web-ui/src/stores/google-drive-store.ts @@ -115,22 +115,15 @@ export default class GoogleDriveStore { verifyGoogleDriveAccessToken = async () => { const expiry_time = localStorage?.getItem('google_access_token_expiry'); - if (expiry_time) { - const current_epoch_time = Math.floor(Date.now() / 1000); - if (current_epoch_time > Number(expiry_time)) { - try { - //request new access token if invalid - await this.client.requestAccessToken({ prompt: '' }); - } catch (error) { - this.signOut(); - this.setGoogleDriveTokenValid(false); - localStorage.removeItem('google_access_token_expiry'); - botNotification(notification_message.google_drive_error, undefined, { - closeButton: false, - }); - return 'not_verified'; - } - } + if (!expiry_time) return 'not_verified'; + const current_epoch_time = Math.floor(Date.now() / 1000); + if (current_epoch_time > Number(expiry_time)) { + this.signOut(); + this.setGoogleDriveTokenValid(false); + localStorage.removeItem('google_access_token_expiry'); + localStorage.removeItem('google_access_token'); + botNotification(notification_message.google_drive_error, undefined, { closeButton: false }); + return 'not_verified'; } return 'verified'; }; @@ -179,7 +172,6 @@ export default class GoogleDriveStore { async loadFile() { if (!this.is_google_drive_token_valid) return; await this.signIn(); - if (this.access_token) gapi.client.setToken({ access_token: this.access_token }); try { await gapi.client.drive.files.list({