Skip to content

Commit f43bcbd

Browse files
author
Michael Lundbøl
committed
Allow a state to be passed.
1 parent 4bb135a commit f43bcbd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Client.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ public function getAccessToken(): ?AccessToken
289289
* Get the url to redirect users to when setting up a salesforce access token
290290
*
291291
* @param string $redirectUrl
292+
* @param string|null $state
292293
* @return string
293294
*/
294-
public function getLoginUrl(string $redirectUrl): string
295+
public function getLoginUrl(string $redirectUrl, ?string $state = null): string
295296
{
296297
$params = [
297298
'client_id' => $this->clientConfig->getClientId(),
@@ -300,7 +301,12 @@ public function getLoginUrl(string $redirectUrl): string
300301
'grant_type' => 'authorization_code'
301302
];
302303

303-
return rtrim($this->clientConfig->getLoginUrl(), '/') . '/services/oauth2/authorize?' . http_build_query($params);
304+
if (null !== $state) {
305+
$params['state'] = $state;
306+
}
307+
308+
return rtrim($this->clientConfig->getLoginUrl(), '/') . '/services/oauth2/authorize?' .
309+
http_build_query($params, '', '&', PHP_QUERY_RFC1738);
304310
}
305311

306312
/**

0 commit comments

Comments
 (0)