Skip to content

Commit

Permalink
Allow a state to be passed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Lundbøl committed Feb 4, 2019
1 parent 4bb135a commit f43bcbd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ public function getAccessToken(): ?AccessToken
* Get the url to redirect users to when setting up a salesforce access token
*
* @param string $redirectUrl
* @param string|null $state
* @return string
*/
public function getLoginUrl(string $redirectUrl): string
public function getLoginUrl(string $redirectUrl, ?string $state = null): string
{
$params = [
'client_id' => $this->clientConfig->getClientId(),
Expand All @@ -300,7 +301,12 @@ public function getLoginUrl(string $redirectUrl): string
'grant_type' => 'authorization_code'
];

return rtrim($this->clientConfig->getLoginUrl(), '/') . '/services/oauth2/authorize?' . http_build_query($params);
if (null !== $state) {
$params['state'] = $state;
}

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

/**
Expand Down

0 comments on commit f43bcbd

Please sign in to comment.