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

$options do not override JWT in getAccessToken #42

Open
tayeke opened this issue Nov 10, 2022 · 0 comments
Open

$options do not override JWT in getAccessToken #42

tayeke opened this issue Nov 10, 2022 · 0 comments

Comments

@tayeke
Copy link

tayeke commented Nov 10, 2022

The method getAccessToken (https://github.com/patrickbussmann/oauth2-apple/blob/main/src/Provider/Apple.php#L236) does not use the $options override when creating the JWT token. The practical example for this is that I need to set a specific client_id for the request. The result now is that I have a client_id in the request payload that matches, but the sub (client_id) in the payload of the client_secret JWT doesn't match.

public function getAccessToken($grant, array $options = [])
{
    $configuration = $this->getConfiguration();
    $time = new \DateTimeImmutable();
    $time = $time->setTime($time->format('H'), $time->format('i'), $time->format('s'));
    $expiresAt = $time->modify('+1 Hour');
    $expiresAt = $expiresAt->setTime($expiresAt->format('H'), $expiresAt->format('i'), $expiresAt->format('s'));

    $token = $configuration->builder()
        ->issuedBy($this->teamId)
        ->permittedFor('https://appleid.apple.com')
        ->issuedAt($time)
        ->expiresAt($expiresAt)
        ->relatedTo($this->clientId) // THIS LINE SHOULD USE CLIENT_ID FROM $OPTIONS IF PRESENT
        ->withHeader('alg', 'ES256')
        ->withHeader('kid', $this->keyFileId)
        ->getToken($configuration->signer(), $configuration->signingKey());

    $options += [
        'client_secret' => $token->toString()
    ];

    return parent::getAccessToken($grant, $options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant