DEV Community

OIDC Authentication with React & Identity Server 4

Andy on July 26, 2020

I put this small demo together with the following objectives: Authenticate a React app user via Identity Server 4 using OIDC. Store authenticated...
Collapse
 
wapenshaw profile image
Siddharth Abbineni

@tappyy Hey, Now that you have a local identity server you are able to manage users and roles with ASP NET Identity and directly query the API. However in cases where one has to use a 3rd Party OIDC/Identity Provider, how would you store user data in your API database for referential purposes?

Collapse
 
carduscarv profile image
Cardus Crvil • Edited

hi, what great article! this is help me a lot to solve my sso implement problem.

i can login to my apps now, but i have an issue on the console.. it gave me 'consent_required' error till i got 'user signed out'. I love to ask if you know how to solve it..

thank you!

Collapse
 
tappyy profile image
Andy

Hey Cardus,

I set "requireConsent" to false in the Identity config to bypass the consent page. Have you done this too?

Collapse
 
hari9526 profile image
Harikrishnan R • Edited

I am not able to login. When I type 'alice' for username and password, nothing happens and I get an error in the console like this

Refused to connect to 'ws://localhost:50071/IdentityServer/' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

Is there something I am missing?

Collapse
 
nonbob profile image
nonbob • Edited

In my experience, you need to disable hot reload. There are a number of places you can disable this, but for me the critical one was in the Launch Profiles dialog in Visual Studio. You get to it from the Debug section of a project's properties (at least in VS 2022, which is what I'm using).

dev-to-uploads.s3.amazonaws.com/up...

Collapse
 
jinyanghuang profile image
Jinyang (Michael) Huang

Hi, I followed you code and everything works fine. However, if I enter a sub-page and refresh the page, it goes blank. Do you know why and how to fix that?

Collapse
 
jinyanghuang profile image
Jinyang (Michael) Huang

I noticed that it is due to the user info being reset every time. So it is redirected to login page and then main page. Is there a way to solve this?

Collapse
 
tappyy profile image
Andy

You could persist the user data in local storage or use something like redux-persist to manage the state rehydration for you :)

Collapse
 
anjkr profile image
anj-kr

Are you able to resolve this ? I'm facing the same issue when reloading the application, it is triggering the flow again. Please let me know

Thanks - Dan

Collapse
 
programmvilli profile image
programmvilli

Thank you for this article. Will hopefully work for my project :)

Collapse
 
maulikgajera profile image
Maulik Gajera • Edited

Hello, I have used your article, project runs and authenticate in my local system, but when i deployed it to IIS server with domain configurations it gave me error of 'un_authorized client'. Can you please help with it?

Thanks.

Collapse
 
jontycool profile image
Tathagat Mohanty

Any help for adding Silent Renewal to this project ? Because after 20-30 mins I am getting idp claim missing error

Collapse
 
sfmb profile image
Fraser

Did you get any further with this issue?

Collapse
 
cubikca profile image
Brian Richardson

Thanks for the primers on Identity Server. Was getting a bit lost.