diff --git a/src/Entities/AuthCodeEntityInterface.php b/src/Entities/AuthCodeEntityInterface.php index f1033af1..00e939c2 100644 --- a/src/Entities/AuthCodeEntityInterface.php +++ b/src/Entities/AuthCodeEntityInterface.php @@ -17,7 +17,7 @@ interface AuthCodeEntityInterface extends TokenInterface public function getRedirectUri(); /** - * @param string|null $uri + * @param string $uri */ public function setRedirectUri($uri); } diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 53b2853d..79a1ac47 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -407,7 +407,10 @@ abstract class AbstractGrant implements GrantTypeInterface $authCode->setExpiryDateTime((new \DateTime())->add($authCodeTTL)); $authCode->setClient($client); $authCode->setUserIdentifier($userIdentifier); - $authCode->setRedirectUri($redirectUri); + + if ($redirectUri !== null) { + $authCode->setRedirectUri($redirectUri); + } foreach ($scopes as $scope) { $authCode->addScope($scope); diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index d1669b2f..81152338 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -270,7 +270,11 @@ class AuthCodeGrant extends AbstractAuthorizeGrant $authorizationRequest->setGrantTypeId($this->getIdentifier()); $authorizationRequest->setClient($client); $authorizationRequest->setRedirectUri($redirectUri); - $authorizationRequest->setState($stateParameter); + + if ($stateParameter !== null) { + $authorizationRequest->setState($stateParameter); + } + $authorizationRequest->setScopes($scopes); if ($this->enableCodeExchangeProof === true) { diff --git a/src/Grant/ImplicitGrant.php b/src/Grant/ImplicitGrant.php index 19e3e684..80c34869 100644 --- a/src/Grant/ImplicitGrant.php +++ b/src/Grant/ImplicitGrant.php @@ -177,7 +177,11 @@ class ImplicitGrant extends AbstractAuthorizeGrant $authorizationRequest->setGrantTypeId($this->getIdentifier()); $authorizationRequest->setClient($client); $authorizationRequest->setRedirectUri($redirectUri); - $authorizationRequest->setState($stateParameter); + + if ($stateParameter !== null) { + $authorizationRequest->setState($stateParameter); + } + $authorizationRequest->setScopes($finalizedScopes); return $authorizationRequest; diff --git a/src/RequestTypes/AuthorizationRequest.php b/src/RequestTypes/AuthorizationRequest.php index 150c920b..5faa45d4 100644 --- a/src/RequestTypes/AuthorizationRequest.php +++ b/src/RequestTypes/AuthorizationRequest.php @@ -183,7 +183,7 @@ class AuthorizationRequest } /** - * @param string|null $state + * @param string $state */ public function setState($state) {