Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve token construction logic and change key getter to public #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Provider/Apple.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function createAccessToken(array $response, AbstractGrant $grant)
/**
* @return string[] Apple's JSON Web Keys
*/
private function getAppleKeys()
public function getAppleKeys()
{
$response = $this->httpClient->request('GET', 'https://appleid.apple.com/auth/keys');

Expand Down
18 changes: 5 additions & 13 deletions src/Token/AppleAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ class AppleAccessToken extends AccessToken
*/
public function __construct(array $keys, array $options = [])
{
if (array_key_exists('refresh_token', $options)) {
if (empty($options['id_token'])) {
throw new InvalidArgumentException('Required option not passed: "id_token"');
}

if (array_key_exists('id_token', $options)) {
$this->idToken = $options['id_token'];
$decoded = null;
$last = end($keys);
foreach ($keys as $key) {
Expand Down Expand Up @@ -71,16 +68,11 @@ public function __construct(array $keys, array $options = [])
$this->isPrivateEmail = $payload['is_private_email'];
}
}

parent::__construct($options);

if (isset($options['id_token'])) {
$this->idToken = $options['id_token'];
}

if (isset($options['email'])) {
else if (isset($options['email'])) {
$this->email = $options['email'];
}

parent::__construct($options);
}

/**
Expand Down