Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Lab 06 is not working #3

Open
PSausM opened this issue Jul 11, 2018 · 4 comments
Open

Lab 06 is not working #3

PSausM opened this issue Jul 11, 2018 · 4 comments

Comments

@PSausM
Copy link

PSausM commented Jul 11, 2018

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
Copy link
Owner

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
Copy link
Author

PSausM commented Jul 11, 2018

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
Copy link
Owner

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
Copy link
Author

PSausM commented Jul 11, 2018

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants