How can I verify token and get user details in keycloak?

Viewed 1873

I implemented keycloak in my nodejs application for registered users on keycloak, for login API i used API:

http://localhost:8080/auth/realms/master/protocol/openid-connect/token

it's return login users's token if username and password is correct,

Now I need to pass this token(return by above API) and check this token is correct or not and if token is correct I need user details, is there any API for this.

Thanks in advance

1 Answers

Now I need to pass this token(return by above API) and check this token is correct or not

You will need to use the introspection endpoint from the Keycloak Documentation:

token_introspection_endpoint

A OAuth2-compliant Token Introspection Endpoint which clients can use to query the server to determine the active state of an RPT and to determine any other information associated with the token, such as the permissions granted by Keycloak.

and if token is correct I need user details, is there any API for this.

For that you need to use the userinfo_endpoint

Both endpoints can be found under the following link:

{KEYCLOAK_URL}/auth/realms/{REALM_NAME}/.well-known/openid-configuration 
Related