1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

Code review changes

This commit is contained in:
Matej Bačo 2022-02-03 11:57:04 +00:00
parent aa4d397758
commit 3fe98a6f30
2 changed files with 8 additions and 3 deletions

View file

@ -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);

View file

@ -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.