Skip to content

Commit

Permalink
feat: add refreshToken to apple provider (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchayn authored May 13, 2023
1 parent e98701b commit 36b9c60
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Lcobucci\JWT\Validation\Constraint\LooseValidAt;
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
use Psr\Http\Message\ResponseInterface;
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
use SocialiteProviders\Manager\OAuth2\User;

Expand Down Expand Up @@ -275,4 +276,29 @@ public function revokeToken(string $token, string $hint = 'access_token')
],
]);
}

/**
* Acquire a new access token using the refresh token.
*
* Refer to the documentation for the response structure (the `refresh_token` will be missing from the new response).
*
* @see https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse
*
* @param string $refreshToken
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return ResponseInterface
*/
public function refreshToken(string $refreshToken): ResponseInterface
{
return $this->getHttpClient()->post($this->getTokenUrl(), [
RequestOptions::FORM_PARAMS => [
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken,
],
]);
}
}

0 comments on commit 36b9c60

Please sign in to comment.