---
schema_version: "1"
id: 38efb4bca96f07ff42365c44681802e95cd9742466d84561090ef46af979f12c
title: Getting User Info JavaScript Examples
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/security/headless-identity-impl-guide/guides/headless-identity/headless-identity-javascript-getuserinfo.md
canonical_url: https://developer.salesforce.com/docs/platform/headless-identity-impl-guide/guide/headless-identity-javascript-getuserinfo.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a902f62b4253375209bc76c837f9a459ff0dd6f925a6db31ee249186735fc8b3
products:
  - Headless Identity Implementation Guide
  - Security
---

# 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.

```nolang
 function getUserInfo(accessToken) {
    client = new XMLHttpRequest();
    client.open("GET", expDomain + userInfoURI, true);
    client.setRequestHeader("Content-Type", "application/json");
    client.setRequestHeader("Authorization", 'Bearer '  + accessToken);
    client.send(); 

    client.onreadystatechange = function() {
        if(this.readyState == 4) {
            if (this.status == 200) {
                //User Info response
                console.log(client.response);
            } else {
                console.log(client.response)
                onError("An Error Occured during Forgot Password Step: " + forgotPasswordProcessStep, client.response); 
            }
        } 
    }
}
```

