Skip to content

Commit

Permalink
[BOT] mayuran/FEQ-2478/TrackJS Dbot - 400 : POST https://oauth2.googl…
Browse files Browse the repository at this point in the history
…eapis.com/revoke (deriv-com#17489)

* fix: expired token 403 issue

* fix: signout on 403 issue
  • Loading branch information
mayuran-deriv authored Nov 15, 2024
1 parent 15e9399 commit bfb0dfa
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions packages/bot-web-ui/src/stores/google-drive-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit bfb0dfa

Please sign in to comment.