Request user information
Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.
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://api.asgardeo.io/t/{organization_name}/oauth2/userinfo
Sample request
- cURL
- JavaScript - jQuery
- Nodejs - Axios
curl --location --request GET 'https://api.asgardeo.io/t/{organization_name}/oauth2/userinfo' \
--header 'Authorization: Bearer {your_access_token}'
var settings = {
"url": "https://api.asgardeo.io/t/{organization_name}/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://api.asgardeo.io/t/{organization_name}/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 Platform 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.
Was this page helpful?