Skip to content

Commit

Permalink
Use proper token expiry error
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Sep 30, 2021
1 parent 14a4d7c commit e9b6eed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AmznSPAHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private function call(string $method, string $url, array $data = [], bool $grant

private function shouldRefreshToken(array $response): bool
{
return Arr::get($response, 'error') === 'expired_token';
return Arr::get($response, 'errors.0.details') === 'The access token you provided has expired.';
}

private function shouldRetry(): bool
Expand Down
9 changes: 7 additions & 2 deletions tests/stubs/errors/token-expired.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"error_description": "This is a placeholder error until we can generate a real one TODO",
"error": "expired_token"
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "Unauthorized",
"details": "The access token you provided has expired."
}
]
}

0 comments on commit e9b6eed

Please sign in to comment.