Reputation: 9441
Correct me if I'm not understanding something. I'm working with a fresh Web API application generated from a VS template.
ValuesController
has the [Authorize]
.I guess all the work needs to be done from an external trusted client application (which must have access to the same database that stores user info). From the client application, how would I create an access token so that I can make a request that would have that access token in the header?
Suppose that I was able to achieve generating an acceptable access token from the client. Will the [Authorize]
attribute still block access because the user would technically not be logged in? Or does [Authorize]
actually log the user in if it doesn't result in a 401?
Upvotes: 0
Views: 794
Reputation: 1349
Your steps are all right. But i think you are mixing you understanding of the last part with cookies authentication and token authentication.
Will the [Authorize] attribute still block access because the user would technically not be logged in? Or does [Authorize] actually log the user in if it doesn't result in a 401?
With cookie authentication this would be a problem that the user would technically need to be logged in and a valid session would need to exist on the server.
However this would not be the case on with token authentication. As long as you have a valid bearer token, you may access the api from any device.
Upvotes: 0
Reputation: 366
The AuthorizeAttribute
will block access when the IsAuthenticated
property of the current IIdentity
is false. This is entirely separated from the access token.
Upvotes: 1