From 56dee88ceed43d70135895bb98497d8177da7e3f Mon Sep 17 00:00:00 2001 From: Tobias Knapp Date: Wed, 20 Oct 2021 16:20:54 +0200 Subject: [PATCH] Initiate new login process if requesting a new token with refresh_token is not successful. --- package.json | 2 +- src/AuthService.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4acbd24..c6c16e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-oauth2-pkce", - "version": "2.0.7", + "version": "2.0.8", "description": "Authenticate against generic OAuth2 using PKCE", "author": "Gardner Bickford ", "license": "MIT", diff --git a/src/AuthService.ts b/src/AuthService.ts index d4d1d8c..bc8f83f 100644 --- a/src/AuthService.ts +++ b/src/AuthService.ts @@ -236,6 +236,10 @@ export class AuthService { method: 'POST', body: toUrlEncoded(payload) }) + if (isRefresh && !response.ok) { + await this.logout() + await this.login() + } this.removeItem('pkce') let json = await response.json() if (isRefresh && !json.refresh_token) {