You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Promise that resolves to the authorization code object returned from Model#saveAuthorizationCode(). In case of an error, the promise rejects with one of the error types derived from OAuthError.
Therefore, we must use Promise.prototype.catch() and try-catch together.
Agreed, also it seems that error handling in general could be better.
Inside model.getClient return Promise.reject(false) - Works correctly and throws invalid_credentials error. return Promise.reject(new Error('Reason')) - Instead throws an invalid_grants error.
It would be really nice when Errors are returned, the handler should reject and pass the error back up the chain.
Thank you for a wonderful library!
environment
v3.0.0
v6.10.3
In the document (OAuth2Server — oauth2-server 3.0.0 documentation) , it says that exceptions are returned by
Promise.reject()
, but some arethrow
n.Therefore, we must use
Promise.prototype.catch()
andtry-catch
together.An example
all codes
clientId
is valid thenauthorized
clientId
is invalid thencatch error in promise { invalid_client: Invalid client: client credentials are invalid ...
clientId
isnull
thencatch error in try-catch { invalid_request: Missing parameter: client_id ...
Reason
AuthorizeHandler.prototype.handle
callsthis.getClient
beforePromise
chain start.AuthorizeHandler.prototype.getClient
throw Error ifclient_id
parameter is missing.Promise.reject()
, the exception will be transmitted to the outside.What is the reason for not unified with
Promise.reject()
?(Not limited to
AuthorizeHandler.prototype.handle
)Thanks in advance.
The text was updated successfully, but these errors were encountered: