Open esteban-filardi opened 4 years ago
I am looking for something similar.
The token() method returns an error in the following format in case a wrong set of credentials is used.
{ "error": "invalid_grant", "error_description": "Invalid grant: user credentials are invalid" }
What I intend to do is to return an appropriate _errordescription depending on the reason for grant failure. Example: User account does not exist. User account is not verified. Incorrect password.
Does anyone have any idea of how I could achieve this?
@esteban-filardi you can access response of the token()
method by accessing it from the response which will be available to you in the next handler, res.locals.oauth.token
. Refer https://github.com/oauthjs/express-oauth-server/blob/master/index.js#L116
The requirement for my app is the following:
"Log all incoming requests (including the request's response body)".
Even if there is the option continueMiddleware to continue executing a following middleware, it isn't possible to access the response of the token() method in that next middleware. Because of that, I can't easily log the response of the API method to obtain a token.
Maybe it would be feasible to store the response body inside the res object before send it in order to be able to have access it in the following middlewares of the chain.
Alternatively, an option could be added to just obtaining the response body of oauth-node-server but not sending it over automatically.