Membrane API Gateway returns 500 Internal Server Error from the token endpoint of the oauth2authserver plugin when that endpoint throws an unexpected exception while it handles a token request. In most cases the client sent parameters that the endpoint cannot parse.
The response contains the status 500 Internal Server Error and the problem type https://membrane-api.io/problems/internal. The type internal means that the gateway could not complete the processing of the message. The endpoint always hides the details, so the title reads Internal Server Error, and the response contains neither an error message nor a link to this page, even in development mode. You find the link to this page in the gateway log.
The oauth2authserver plugin turns Membrane into an OAuth2 authorization server. Clients exchange an authorization code, a refresh token or their credentials for tokens at <basePath>/oauth2/token. Regular protocol errors do not lead to this 500: missing or wrong parameters, unknown clients and wrong secrets get an OAuth2 JSON error such as invalid_request or unauthorized_client. For the flows in general, see the authorization code flow tutorial.
The endpoint parses the query string and the form body strictly. If a parameter occurs more than once, for example grant_type twice, parsing fails with Could not parse query.
A value contains a malformed percent-escape, such as %G1 or a lone %, so URL decoding fails.
The request URI cannot be parsed, or the request body cannot be read or decoded, for example because of a wrong Content-Encoding or an interrupted transfer.
Creating the access, refresh or ID token failed, for example because signing the ID token failed. The cause is a misconfigured key or token generator on the oauth2authserver, or a bug in Membrane.
error level and tells parameter errors apart from token creation errors.oauth2authserver.The token endpoint always answers as if the gateway were running in production mode. Setting or removing production: true in the configuration does not change this response: the client gets neither the details nor the link to this page. Membrane writes the full error, including the stack trace, to the gateway log at error level. That log entry is the place to start.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.