thephpleague / oauth2-client

Easy integration with OAuth 2.0 service providers.

Home Page:http://oauth2-client.thephpleague.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding additional parameter

LeonardoDB opened this issue · comments

hello,

I can add additional params to authorizationUrl using the library API?

I couldn't add this error=true, I think the lib doesn't allow adding new parameters inside the GenericProvider to be automatically added to url authorizationUrl, for example: https://my-authentication/login?error=true.......

Which option would be better?

@LeonardoDB You can pass your additional parameters to URL using getAuthorizationUrl() function.

Ex.:

$oauthClient = new \League\OAuth2\Client\Provider\GenericProvider([
            'clientId' => config('azure.appId'),
            'clientSecret' => config('azure.appSecret'),
            'redirectUri' => config('azure.redirectUri'),
            'urlAuthorize' => config('azure.authority') . config('azure.authorizeEndpoint'),
            'urlAccessToken' => config('azure.authority') . config('azure.tokenEndpoint'),
            'urlResourceOwnerDetails' => '',
            'scopes' => config('azure.scopes'),
            'prompt' => 'consent'
        ]);

$authUrl = $oauthClient->getAuthorizationUrl(['prompt' => 'select_account']);

in above code, I am passing 'prompt' parameter to url.