Reputation: 178
Hi I am using Bearer authentication in my web api 2. After user login i generate access token to the user. Further when they request my web api, they have to send access token in request header. All valid access tokens are requesting web api with out any problem. But I am not sure how to handle bad access tokens (expired). Please let me know the solution if you have. Thanks in advance.
Upvotes: 0
Views: 671
Reputation: 631
In addition to Mahesh Kava, you may extend AuthorizeAttribute class to return more detailed information for unauthorized request. Refer to this SO question
Upvotes: 1
Reputation: 791
You should use the [Authorize]
filter attribute to authorize the request. All bad request with expired tokens will be treated with a 401 unauthorized error
Upvotes: 1