I am using Laravel 5.3 for the REST server that the mobile application is connecting to. I already set up an exception handler for most Laravel errors and worked the way I like.
However, OAuth errors return ugly. Example:
{ "error":"invalid_credentials", "message":"The user credentials were incorrect." }
Apparently, I'm not the only one bothered by the underlined error code β I only have a few beta testers, and they have already reported this as an βerror.β
The passport seems to bypass the regular error handler and pass through League\OAuth2\Server\Exception\OAuthServerException . These ugly error messages are hardcoded to this file.
public static function invalidCredentials() { return new static('The user credentials were incorrect.', 6, 'invalid_credentials', 401); }
I seriously tried, like a dozen approaches to extending / overriding OAuthServerException, but I just can't get it to work.
source share