IdentityModel / AuthorizationServer

Sample implementation of an OAuth2 Authorization Server
Other
280 stars 136 forks source link

401 (Unauthorized) on ResourceServer for Code Flow #232

Closed rhoadesm64 closed 9 years ago

rhoadesm64 commented 9 years ago

I have AS up and running and loaded with the sample data. I have been trying to run the Code Flow in the Flows samples that are available. Everything works fine until I do the Call Service and that is where I am getting the 401. I have confirmed the IssuerName, Audience, and SigningKey but nothing seems to work. Since there is no tracing from the ResourceSever V2 I am not sure where to go from here. Any ideas.

Thanks

leastprivilege commented 9 years ago

That's how you can turn on tracing:

https://katanaproject.codeplex.com/wikipage?title=Debugging&referringTitle=Documentation

rhoadesm64 commented 9 years ago

I turned on tracing and was able to get the following error: Jwt10316: Signature validation failed.

After reading through some posts for this I switched my application in AS to use the symmetric key. This got me a little farther.

So now I get the following error: Jwt10315: Signature validation failed

Does the symmetric key need to match the symmetric key for the RP in Identity Server?

My understanding is that the resource server will call into Authorization Server which calls the Identity Server for authentication. Is this correct? Does it use the client that I used to originally get the token from the AS?

Thanks

rhoadesm64 commented 9 years ago

Update....

After my last post I decided to go back to the samples that come with AS. I tried the code flow and it now works. I guess this has to do with switching to the symmetric key. I will now go back to my test application that I was working on and see what the differences were there.

Thanks

rhoadesm64 commented 9 years ago

Update....

I had to make changes to my web.config file, so now my test application is working.

Thanks

rhoadesm64 commented 9 years ago

I have now added authentication to my application via Thinktecture Identity Server. So I have the authentication working. The Authorization server works until the following code runs

var response = client.GetAsync("identity").Result;

Then I get the 401 again. So if I take out authentication the authorization will work but for some reason I cannot get them to work together.

Is something being passed from the claims for authentication to authorization? Any ideas on this?

Thanks

leastprivilege commented 9 years ago

But this

var response = client.GetAsync("identity").Result;

is calling an API - not AS or IdSrv

again - turn on Katana logging to see what's going on.

rhoadesm64 commented 9 years ago

I actually got it to work but I am not sure what I changed to make it work.

Thanks