scolapicchioni / spa20

PWA - ASP.NET Core 2.0 - VueJs 2 - IdentityServer 4 - Material Design
34 stars 8 forks source link

Lab 06 is not working #3

Open PSausM opened 6 years ago

PSausM commented 6 years ago

When you checkout Lab 06 solution, run the spa client and the identity server. Login from the spa client you get redirected to identity server. you login and the authenticated.

I get an error message: "Invalid redirect_uri: http://localhost:5001/#/callback#"

Strange thing is: I put a / between callback and # Why is it not going to identity server? you stay on the login page. you are not redirected back to the spa client.

Otherwise it is a fantastic tutorial! Congrats!

scolapicchioni commented 6 years ago

Thanks for your message. Did you seed all the databases first? The readme.md on the root of this project tells you the steps you need, did you follow them first?

If you want to see the final application

Configure and start the Identity Server Application Open Lab08\Solution\MarketPlace\IdentityServer\IdentityServer.sln in Visual Studio Build the project but do not start it from Visual Studio Open a command prompt under the Lab08\Solution\MarketPlace\IdentityServer folder Type dotnet run /seed Navigate to http://localhost:5002 and ensure that the project is up and running

Configure and start the REST Service Open Lab08\Solution\MarketPlace\Marketplace\MarketPlace.sln in Visual Studio Build the project and start it from Visual Studio

Configure and start the Javascript client Open Lab08\Solution\MarketPlace\spaclient in Visual Studio Code Open a terminal window Type npm install Type npm run dev

If you did, does the Identity Server project log any error?

PSausM commented 6 years ago

Yes I seeded and get a message that I loged in successfully. But I get the error message I added in my first post. Forgot that, sorry.

scolapicchioni commented 6 years ago

It is weird, I don't know where that address is coming from... On both projects in the solution I read this address http://localhost:5001/#/callback/# and not the one you have, (which is missing a /) which should mean that the value seeded in the database of IdentityServer and the one given from the client should match...

I'm going to try to find the problem as soon as possible, but in the meantime you could try this workaround to see if it fixes the problem.

The important thing is that the IdentityServer database (not the code, because the code is only used during the seed fase) and the value provided by the spa client match.

One thing you could try is 1) check the code in https://github.com/scolapicchioni/spa20/blob/master/Lab06/Solution/MarketPlace/IdentityServer/IdentityServerWithAspIdAndEF/Config.cs and verify that the RedirectUris of the JavaScript Client is http://localhost:5001/#/callback/# If not, modify it, then drop the database and seed it again

2) check the code in https://github.com/scolapicchioni/spa20/blob/master/Lab06/Solution/MarketPlace/spaclient/src/applicationusermanager.js and verify that redirect_uri property is set to http://localhost:5001/#/callback/# If not, modify it. 3) Open the database (you're going to need SQLite Compact Toolbox Plugin https://marketplace.visualstudio.com/items?itemName=ErikEJ.SQLServerCompactSQLiteToolbox for Visual Studio if you want to open it from there) and check that the table ClientRedirectUris contains http://localhost:5001/#/callback/#

Hope this helps.

PSausM commented 6 years ago

Ok, I've found the problem. It is only working with Kestrel. I used IIS Express to run Identity Server and was not redirected. With Kestrel it works. Can you confirm that?