diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index cd997d3be..abe642b51 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1714,6 +1714,11 @@ App::patch('/v1/account/sessions/:sessionId') $appSecret = $project->getAttribute('providers', [])[$provider.'Secret'] ?? '{}'; $className = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider); + + if (!\class_exists($className)) { + throw new Exception('Provider is not supported', 501); + } + $oauth2 = new $className($appId, $appSecret, '', [], []); $oauth2->refreshTokens($refreshToken); diff --git a/src/Appwrite/Auth/OAuth2.php b/src/Appwrite/Auth/OAuth2.php index 9b4c3b938..4eafba761 100644 --- a/src/Appwrite/Auth/OAuth2.php +++ b/src/Appwrite/Auth/OAuth2.php @@ -124,7 +124,7 @@ abstract class OAuth2 public function getAccessToken(string $code):string { $tokens = $this->getTokens($code); - return $tokens['access_token']; + return $tokens['access_token'] ?? ''; } /** @@ -135,7 +135,7 @@ abstract class OAuth2 public function getRefreshToken(string $code):string { $tokens = $this->getTokens($code); - return $tokens['refresh_token']; + return $tokens['refresh_token'] ?? ''; } /** @@ -146,7 +146,7 @@ abstract class OAuth2 public function getAccessTokenExpiry(string $code):string { $tokens = $this->getTokens($code); - return $tokens['expires_in']; + return $tokens['expires_in'] ?? ''; } // The parseState function was designed specifically for Amazon OAuth2 Adapter to override.