patrickbussmann / oauth2-apple

Sign in with Apple Provider for the OAuth 2.0 Client
MIT License
96 stars 65 forks source link

Is possible add state option for provider #40

Closed huthief closed 2 years ago

huthief commented 2 years ago

At League/oauth2-client, we can add state option at provider's option array. But it's not work at oauth2-apple. Is possible add state option for provider like this?

$provider = new League\OAuth2\Client\Provider\Apple([ 'clientId' => '{apple-client-id}', 'teamId' => '{apple-team-id}', // 1A234BFK46 https://developer.apple.com/account/#/membership/ (Team ID) 'keyFileId' => '{apple-key-file-id}', // 1ABC6523AA https://developer.apple.com/account/resources/authkeys/list (Key ID) 'keyFilePath' => '{apple-key-file-path}', // DIR . '/AuthKey_1ABC6523AA.p8' -> Download key above 'redirectUri' => 'https://example.com/callback-url', 'state' => 'customize state string', 'scope' => ['name', 'email'], ]);

huthief commented 2 years ago

I got the answer XD

$options = [ 'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE', // Scopes: https://developer.apple.com/documentation/authenticationservices/asauthorizationscope 'scope' => ['name', 'email'] // array or string ];

$authorizationUrl = $provider->getAuthorizationUrl($options);