Skip to content

Commit 7c2c8d0

Browse files
include interval on authorization_pending and slow_down error responses
1 parent bc6b12f commit 7c2c8d0

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/Exception/OAuthServerException.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ public static function expiredToken(?string $hint = null, ?Throwable $previous =
215215
return new static($errorMessage, 11, 'expired_token', 400, $hint, null, $previous);
216216
}
217217

218-
public static function authorizationPending(string $hint = '', ?Throwable $previous = null): static
218+
public static function authorizationPending(?int $interval = null, string $hint = '', ?Throwable $previous = null): static
219219
{
220-
return new static(
220+
$exception = new static(
221221
'The authorization request is still pending as the end user ' .
222222
'hasn\'t yet completed the user interaction steps. The client ' .
223223
'SHOULD repeat the Access Token Request to the token endpoint',
@@ -228,6 +228,15 @@ public static function authorizationPending(string $hint = '', ?Throwable $previ
228228
null,
229229
$previous
230230
);
231+
232+
if (!is_null($interval)) {
233+
$exception->setPayload([
234+
...$exception->getPayload(),
235+
'interval' => $interval,
236+
]);
237+
}
238+
239+
return $exception;
231240
}
232241

233242
/**
@@ -236,9 +245,9 @@ public static function authorizationPending(string $hint = '', ?Throwable $previ
236245
*
237246
* @return static
238247
*/
239-
public static function slowDown(string $hint = '', ?Throwable $previous = null): static
248+
public static function slowDown(?int $interval = null, string $hint = '', ?Throwable $previous = null): static
240249
{
241-
return new static(
250+
$exception = new static(
242251
'The authorization request is still pending and polling should ' .
243252
'continue, but the interval MUST be increased ' .
244253
'by 5 seconds for this and all subsequent requests.',
@@ -249,6 +258,15 @@ public static function slowDown(string $hint = '', ?Throwable $previous = null):
249258
null,
250259
$previous
251260
);
261+
262+
if (!is_null($interval)) {
263+
$exception->setPayload([
264+
...$exception->getPayload(),
265+
'interval' => $interval,
266+
]);
267+
}
268+
269+
return $exception;
252270
}
253271

254272
/**

0 commit comments

Comments
 (0)