Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748<?php
declare(strict_types=1);
namespace Wotnak\Atproto\Exception;
/** * OAuth endpoint response with a non-success HTTP status. * * @api */final class OAuthHttpException extends OAuthException {
/** * @param array<string, mixed> $responseData */ public function __construct( public readonly string $endpoint, public readonly int $statusCode, public readonly ?string $oauthError, public readonly ?string $oauthErrorDescription, public readonly array $responseData, public readonly ?string $grantType = NULL, ) { $message = \sprintf('OAuth %s request failed with HTTP %d.', $endpoint, $statusCode); if ($oauthError !== NULL) { $message .= ' ' . $oauthError; if ($oauthErrorDescription !== NULL && $oauthErrorDescription !== '') { $message .= ': ' . $oauthErrorDescription; } } parent::__construct($message); }
/** * Returns whether the response proves that the refresh token is unusable. */ public function definitivelyRejectsRefreshToken(): bool { return ( \in_array($this->endpoint, ['token'], TRUE) && \in_array($this->grantType, ['refresh_token'], TRUE) && $this->statusCode === 400 && \in_array($this->oauthError, ['invalid_grant'], TRUE) ); }
}