Membrane API Gateway returns 500 with the title OAuth2 Error from Authentication Server when the authorization server sends the browser back to the OAuth2 callback of the oauth2Resource2 plugin with an error instead of an authorization code. The authorization server refused the login. This is not a malfunction of Membrane.
The response contains the status 500, the title OAuth2 Error from Authentication Server, the error_description sent by the authorization server as detail, the problem type https://membrane-api.io/problems/security and a link to this page. The type security means that the error occurred during authentication. The user's session is cleared.
The oauth2Resource2 plugin redirects users without a session to the authorization server. After the login, the server redirects the browser back to the callback path of the gateway with a code, which Membrane exchanges for tokens. If the server cannot issue a code, it redirects back with the parameters error and error_description instead, as defined in RFC 6749.
The user aborted the login or did not grant the requested permissions. The error code is usually access_denied.
The gateway requests a scope that the client is not allowed to use. The error code is invalid_scope.
The client ID or the redirect URI configured on the gateway does not match the registration at the authorization server. Typical error codes are unauthorized_client and invalid_request.
The server reported server_error or temporarily_unavailable. Retry later or check the server.
afterErrorUrl on oauth2Resource2. The error and its description are posted to that URL.See OAuth2 using Postman for an example setup.
Unlike most errors, this error is sent with its title, detail and the link to this page even when Membrane runs in production mode. Setting production: true in the configuration document does not remove them. The detail is the description written by the authorization server.
Configuration reference:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.