Skip to content

Request user information

User information is encoded inside the ID token returned along with the access token. In addition to that, OpenID Connect provides the userinfo endpoint to obtain user information as a payload. The application should send a request with the access token to invoke the userinfo endpoint.

Userinfo endpoint

https://localhost:9443/oauth2/userinfo

Sample request

curl --location --request GET 'https://localhost:9443/oauth2/userinfo' \
--header 'Authorization: Bearer {your_access_token}'
var settings = {
    "url": "https://localhost:9443/oauth2/userinfo",
    "method": "GET",
    "timeout": 0,
    "headers": {
        "Authorization": "Bearer {your_access_token}"
    },
};

$.ajax(settings).done(function (response) {
    console.log(response);
});
var axios = require('axios');

var config = {
    method: 'get',
    url: 'https://localhost:9443/oauth2/userinfo',
    headers: {
        'Authorization': 'Bearer {your_access_token}'
    }
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

Default sample response
WSO2 Identity Server returns only the sub claim if there are no user attributes shared with the application.

{
  "sub": "e46ffa67-100d-4329-9460-b8251d446518"
}

You can customize the user information in the response by configuring user attributes on the registered application.