Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distinguish if user is logged in from a Provider or from a user in Keycloak

I am integrating Keycloak into a React Application. I have successfully added Google Providers in Keycloak. Now the user can either log in with Keycloak user's credentials or from Login with Google. After login how to distinguish if a user is with React or with a Provider? And how to acquire the ID of that user so for certain activities to store that ID in the database?

like image 409
Illyrian Avatar asked Oct 19 '25 12:10

Illyrian


1 Answers

GET User's detail REST API detect which identity provider's user.

Get representation of the user

enter image description here

The federatedIdentities fields shows it

enter image description here

here

enter image description here

Demo this user login via google

You needs a master token in Posman.

#1 Get master token at Posman.

Detail instruction here

#2 Get user list

GET http://localhost:8080/auth/admin/realms/my-realm/users

#3 Get google user

GET http://localhost:8080/auth/admin/realms/my-realm/users/{google-user-uuid}

enter image description here

#4 Get regular user

GET http://localhost:8080/auth/admin/realms/my-realm/users/{user-uuid}

This user logged via regular Keycloak enter image description here

like image 128
Bench Vue Avatar answered Oct 22 '25 05:10

Bench Vue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!