# Getting /userinfo from frontend works, but not from backend

**URL:** <https://community.auth0.com/t/getting-userinfo-from-frontend-works-but-not-from-backend/8108>\
**Category:** Get Help\
**Tags:** backend, userinfo\
**Created:** [September 6, 2017, 8:30pm UTC](https://community.auth0.com/t/getting-userinfo-from-frontend-works-but-not-from-backend/8108 "2017-09-06T20:30:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maik\_Vogt](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Maik\_Vogt](https://community.auth0.com/u/Maik_Vogt)\
**Post date:** [September 6, 2017, 8:30pm UTC](https://community.auth0.com/t/getting-userinfo-from-frontend-works-but-not-from-backend/8108/1 "2017-09-06T20:30:30Z")

</div>

I use lock to authenticate on my angular frontend without any problems:

```
  lock = new Auth0Lock(AUTH_CONFIG.clientID, AUTH_CONFIG.domain, {
    oidcConformant: true,
    autoclose: true,
    socialButtonStyle: 'small',
    rememberLastLogin: true,

    auth: {
      redirectUrl: AUTH_CONFIG.callbackURL,
      responseType: 'token id_token',
      audience: `https://${AUTH_CONFIG.domain}/userinfo`,
      params: {
          prompt: 'select_account',
      },
    },
  });

```

Getting userinfo works too:

```
    this.lock.getUserInfo(authResult.accessToken, (err, profile) => {
      localStorage.setItem('profile', JSON.stringify(profile));
      this.router.navigate('/']);
      console.log(profile);
    });

```

However on my nodejs backend I get an Unauthorized 401 message when trying to access /userinfo using the same access token :

```
app.post("/claimAccount", checkJwt, function(req,res){
    var bodyStr = '';
    req.on("data",function(chunk){
        bodyStr += chunk.toString();
    });
    req.on("end",function(){
	try {
		const data = JSON.parse(bodyStr);
   		console.log(req.user);
        console.log(req.headers.authorization);

        var headers = {
            'authorization': req.headers.authorization,
            'content-type': 'application/json'
        };

        var options = {
            url: 'https://etherauth.eu.auth0.com/userinfo',
            headers: headers
        };

        function callback(error, response, body) {
            console.log("statuscode : " + response.statusCode);
            if (!error && response.statusCode == 200) {
                console.log("ui succ: "+body);
            }
        }
        request(options, callback);
 });

```

req.user consists of the following:

```
{ iss: 'https://etherauth.eu.auth0.com/',
  sub: 'facebook|10154740758691918',
  aud: '2eY_5Pf9DxJx1R1CqvJsYPHbwGfbCLDz',
  exp: 1504739649,
  iat: 1504703649,
  nonce: 'saMorzyuLIE7GkyS3FA9SK-_lOfoONSk',
  at_hash: 'zivjSUNooWq38kemfFfQhw' }

```

I cannot just send the userinfo to the backend since there should be no way of spoofing it.

Maybe this is related: How come req.aud equals my ClientID on the backend API call, when I have audience: `https://${AUTH_CONFIG.domain}/userinfo`, in the lock constructor in the frontend?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/getting-userinfo-from-frontend-works-but-not-from-backend/8108/2 "2018-03-02T05:56:21Z")

</div>


