Newer Version Available
Getting User Info JavaScript Examples
When you get an access token via headless registration or headless login, you can
retrieve user information with a request to the User Info endpoint. Use this example to
understand how.
In this example, the access token is passed in an Authorization Bearer header.
1function getUserInfo(accessToken) {
2 client = new XMLHttpRequest();
3 client.open("GET", expDomain + userInfoURI, true);
4 client.setRequestHeader("Content-Type", "application/json");
5 client.setRequestHeader("Authorization", 'Bearer ' + accessToken);
6 client.send();
7
8 client.onreadystatechange = function() {
9 if(this.readyState == 4) {
10 if (this.status == 200) {
11 //User Info response
12 console.log(client.response);
13 } else {
14 console.log(client.response)
15 onError("An Error Occured during Forgot Password Step: " + forgotPasswordProcessStep, client.response);
16 }
17 }
18 }
19}