mikenicholson / passport-jwt

Passport authentication using JSON Web Tokens
MIT License
1.97k stars 214 forks source link

Customizing 401 HTML code #61

Closed MocanuMarius closed 8 years ago

MocanuMarius commented 8 years ago

Hey, is there any way we can possibly customize the error response in case of an error ? Instead of "Unauthorized" , i need to use this with swagger and integrate the default swagger error code but i have no way of doing it.

sdotson commented 8 years ago

Correct me if I'm mistaken, but I think you can define the status code in the response of your node application, e.g., res.status(401) if you're using express.

ebaghern commented 8 years ago

@sdotson You'll need to create a custom callback/middleware for this. Check out: http://passportjs.org/docs/authenticate under custom callback.

mikenicholson commented 8 years ago

@MocanuMarius I think what @ebaghern provided should answer your question. Let me know if not and we can reopen this.