node-oauth2-server icon indicating copy to clipboard operation
node-oauth2-server copied to clipboard

any way for Custom Error Messsage

Open RiteshM opened this issue 13 years ago • 4 comments

i have two doubt

  1. i got the point of implementing all the functions but where function getAccessToken and getRefreshToken utilized or called ?? i get the point from your comment How to implement. 2.when ever i pass an error in any function like

model.saveAccessToken = function (accessToken, clientId, userId, expires, callback) {

callback({'error':'invalid response'},false);

};

then it will give the response { code: 503 error: "server_error" error_description: "server_error" } if there is any custom mistake or error then can i change this response to some thing else manually .can i customize error message using this library??

RiteshM avatar Oct 04 '13 05:10 RiteshM

On the whole, no, you can't create custom errors. This is to encourage compliance with the spec, if you can show me a good example of where a custom error would be useful I would consider implementing it for 2.0.

However, you can invoke error responses based on what you return from the model methods. For example, if you return something falsey from getAccessToken this will invoke a "invalid_token" response. In your example, saveAccessToken, i'm not sure why you would want to pass in a custom error there?

thomseddon avatar Oct 04 '13 06:10 thomseddon

Closing as no example of where a custom error would be useful

thomseddon avatar Oct 16 '13 14:10 thomseddon

old issue but i have a case - maybe you can provide a quick workaround.

I use JWT which required me to rewrite the model.getAccessToken implementation. I use a try/catch block to decode the JTW. If it fails this is usually due to a decoding error, and hence a "invalid_token" error. However it produces a "server_error" - any suggestions?

kreck avatar Feb 12 '16 17:02 kreck

Any updates on this? Being able to create custom messages would be more easier for a lazy ass like me. :smile:

prameshbajra avatar Jun 20 '18 18:06 prameshbajra