OpenID Connect is an authentication protocol that is a simple identity layer on top of the OAuth 2.0 protocol. It allows clients to verify the identity of the end-user based on the authentication performed by an authorization server, as well as to obtain basic profile information about the end-user in an interoperable and REST-like manner.
You can use WSO2 API Manager to obtain basic profile information about the user who generates the access token. To obtain this information, the
openid scope needs to be passed, when generating the access token. API manager will send a JWT which contains information about the user who generates the token, as part of the response for this request. You can configure the information returned with the JWT token.
Follow the instructions below to obtain user profile information with OpenID connect with WSO2 API Manager.
Obtain a token using password grant type and
openidscope. For more information on token generation with password grant type, see Password Grant Type. The format of the curl command and a sample is given below :
You will receive a response in the format shown below. Note that the
id_tokenparameter contains the JWT related to user information.
- The following two options are available to view the actual user information.
Decoding the id_token
By decoding the
id_token, a payload similar to the following can be obtained, with user information such as email, organization, etc.
For an online tool to decode the JWT, go to https://jwt.io/
Invoking the userinfo endpoint
You can obtain user information as a payload by invoking the userinfo endpoint with the access token obtained in step 1. The format of the curl command and a sample is given below
The response will be a JSON payload as shown below:
By default, only the username (sub) information will be available in the response. You can customize the user information returned by configuring the claims of the relevant Service Provider generated for the Application created in Store. For more information, see Service Provider Claim Configuration.