From 20d711b92f3cc8f1aad0fbe715a8a6573776852d Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Tue, 12 Nov 2019 12:56:17 +0530 Subject: [PATCH] Only revoke token if no or invalid refresh token. --- includes/Core/Authentication/Clients/OAuth_Client.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/Core/Authentication/Clients/OAuth_Client.php b/includes/Core/Authentication/Clients/OAuth_Client.php index d374184a81d..4e6b8c27651 100644 --- a/includes/Core/Authentication/Clients/OAuth_Client.php +++ b/includes/Core/Authentication/Clients/OAuth_Client.php @@ -237,7 +237,9 @@ function( $cache_key, $access_token ) { public function refresh_token() { $refresh_token = $this->get_refresh_token(); if ( empty( $refresh_token ) ) { + $this->revoke_token(); $this->user_options->set( self::OPTION_ERROR_CODE, 'refresh_token_not_exist' ); + return; } // Stop if google_client not initialized yet. @@ -257,7 +259,9 @@ public function refresh_token() { $error_code = $e->getMessage(); } // Revoke and delete user connection data if the refresh token is invalid or expired. - $this->revoke_token(); + if ( 'invalid_grant' === $error_code ) { + $this->revoke_token(); + } $this->user_options->set( self::OPTION_ERROR_CODE, $error_code ); return; }