Skip to content

Commit 35c7dc3

Browse files
committed
🔧 success response code for PAR is 201 (fixes #6)
1 parent ddced33 commit 35c7dc3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Core/PARTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public function getParRequestUri(array $body):UriInterface{
4141
$status = $response->getStatusCode();
4242
$json = MessageUtil::decodeJSON($response, true);
4343

44+
// the response should be a 201, see: https://github.com/chillerlan/php-oauth/issues/6
4445
// something went horribly wrong
45-
if($status !== 200){
46+
if($status !== 201){
4647

4748
// @link https://datatracker.ietf.org/doc/html/rfc9126#section-2.3
4849
if(isset($json['error'], $json['error_description'])){

tests/Providers/Unit/OAuth2ProviderUnitTestAbstract.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ public function testGetParAuthURL():void{
9393
// @link https://datatracker.ietf.org/doc/html/rfc9126#name-successful-response
9494
$json = '{"request_uri":"urn:ietf:params:oauth:request_uri:6esc_11ACC5bwc014ltc14eY22c","expires_in":60}';
9595

96-
$this->setMockResponse($this->streamFactory->createStream($json));
96+
$response = $this->responseFactory
97+
->createResponse(201)
98+
->withBody($this->streamFactory->createStream($json))
99+
;
100+
101+
$this->setMockResponse($response);
97102

98103
$uri = $this->provider->getAuthorizationURL();
99104
$params = QueryUtil::parse($uri->getQuery());

0 commit comments

Comments
 (0)