Improve error handling for invalid access token responses#747
Improve error handling for invalid access token responses#747TobMoeller wants to merge 2 commits intolaravel:5.xfrom
Conversation
|
I wonder if the response could be included in the exception? Something that might let developers inspect what is going on. |
|
Thanks for the suggestion! I looked into including the response in the exception, but unfortunately, by the time the exception is thrown, the response has already been processed through json_decode(). This means that any response not containing valid JSON (e.g., an HTML error page or plain text) ends up as null. As a result, we don't have the original response available when raising the exception. Altering the behavior of the If you have other thoughts or an alternative approach, please let me know—I’d be happy to explore it further! |
When an OAuth provider's token endpoint returns an invalid response (non-JSON or missing access_token),
the current code fails with a generic error. This can be confusing when debugging issues,
especially in cases where firewalls or proxy servers intercept the request and return HTML instead
(e.g., Cloudflare access denied pages).
This PR adds an
InvalidTokenResponseExceptionthat is thrown, if the OAuth provider's response does not contain the requiredaccess_token.