Skip to content

Commit

Permalink
Add reauthorization to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Lundbøl committed Feb 26, 2019
1 parent 0929cd9 commit adcaab6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ public function getAccessToken(): ?AccessToken
*
* @param string $redirectUrl
* @param string|null $state
* @param bool $reauthorize
* @return string
*/
public function getLoginUrl(string $redirectUrl, ?string $state = null): string
public function getLoginUrl(string $redirectUrl, ?string $state = null, bool $reauthorize = false): string
{
$params = [
'client_id' => $this->clientConfig->getClientId(),
Expand All @@ -305,12 +306,16 @@ public function getLoginUrl(string $redirectUrl, ?string $state = null): string
'grant_type' => 'authorization_code'
];

if (null !== $state) {
if (null !== $state || '' !== $state) {
$params['state'] = $state;
}

if (true === $reauthorize) {
$params['prompt'] = urlencode('login consent');
}

return rtrim($this->clientConfig->getLoginUrl(), '/') . '/services/oauth2/authorize?' .
http_build_query($params, '', '&', PHP_QUERY_RFC1738);
http_build_query($params, '', '&', PHP_QUERY_RFC3986);
}

/**
Expand Down

0 comments on commit adcaab6

Please sign in to comment.