Skip to content

Commit 5be7017

Browse files
Add method for adding extra authcode params
1 parent 8184f77 commit 5be7017

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Grant/AuthCodeGrant.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ public function respondToAccessTokenRequest(
172172
}
173173
}
174174

175+
// Handle extra authorization code parameters
176+
$this->handleExtraAuthCodeParams($authCodePayload);
177+
175178
// Issue and persist access + refresh tokens
176179
$accessToken = $this->issueAccessToken($accessTokenTTL, $client, $authCodePayload->user_id, $scopes);
177180
$refreshToken = $this->issueRefreshToken($accessToken);
@@ -338,6 +341,8 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization
338341
'code_challenge_method' => $authorizationRequest->getCodeChallengeMethod(),
339342
];
340343

344+
$payload = array_merge($this->getExtraAuthCodeParams($authorizationRequest), $payload);
345+
341346
$response = new RedirectResponse();
342347
$response->setRedirectUri(
343348
$this->makeRedirectUri(
@@ -367,4 +372,26 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization
367372
)
368373
);
369374
}
375+
376+
/**
377+
* Add custom fields to your authorization code to save some data from the previous (authorize) state
378+
* for when you are issuing the token at the token endpoint
379+
*
380+
* @param AuthorizationRequest $authorizationRequest
381+
*
382+
* @return array
383+
*/
384+
protected function getExtraAuthCodeParams(AuthorizationRequest $authorizationRequest)
385+
{
386+
return [];
387+
}
388+
389+
/**
390+
* Handle the extra params specified in getExtraAuthCodeParams
391+
*
392+
* @param object $authCodePayload
393+
*/
394+
protected function handleExtraAuthCodeParams(object $authCodePayload)
395+
{
396+
}
370397
}

0 commit comments

Comments
 (0)