Often is the debugging of oAuth2 errror messages a pain. Luckly the OAuthServerException class implements a hint, which helps finding the issue with failing oAuth2 requests.

Unfortunatly this hint is not saved to watchdog. I made a patch which also logs the hint:

Before:

League\OAuth2\Server\Exception\OAuthServerException: The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. in League\OAuth2\Server\Exception\OAuthServerException::invalidRequest() (line 126 of /home/lessmess/domains/stage.lessmess.io/www/vendor/league/oauth2-server/src/Exception/OAuthServerException.php).

After:

League\OAuth2\Server\Exception\OAuthServerException: The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. in League\OAuth2\Server\Exception\OAuthServerException::invalidRequest() (line 126 of /home/lessmess/domains/stage.lessmess.io/www/vendor/league/oauth2-server/src/Exception/OAuthServerException.php). Hint: Authorization code has been revoked

I hope this small improvement can be reviewed and commited by a maintainer.

CommentFileSizeAuthor
simple_oauth2_error_message_hint.patch804 bytesayalon

Comments

ayalon created an issue. See original summary.

merilainen’s picture

Status: Active » Reviewed & tested by the community

Looks simple and works.

bradjones1’s picture

Status: Reviewed & tested by the community » Active

Thanks for this contribution!

I am marking as active since the last-caller information here is also not very helpful. I am going to convert to a merge-request flow and work on this a bit now.

bradjones1’s picture

Status: Active » Needs work

Quick review - this is in theory what we need, though watchdog_exception() is called in 4 different places in this project, so we should probably centralize the handling. Also, the last-caller information that Drupal generates by default just points to the league package, which isn't particularly helpful, so we should probably override this with context from within this module.

bradjones1’s picture

Version: 8.x-4.5 » 5.x-dev
bojan_dev’s picture

Status: Needs work » Closed (duplicate)