# Get user info using authentication API

**URL:** <https://community.auth0.com/t/get-user-info-using-authentication-api/7153>\
**Category:** Get Help\
**Tags:** userinfo, api-authorization, angularjs-2\
**Created:** [June 20, 2017, 5:15pm UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153 "2017-06-20T17:15:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajira000](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wajira000](https://community.auth0.com/u/wajira000)\
**Post date:** [June 20, 2017, 5:15pm UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/1 "2017-06-20T17:15:18Z")

</div>

I’m new to the Auth0 and angularjs. I start a project using these two technology. I got a problem wile i’m doing this. I manage to get the security token using user name and password. I wanted a custom login page so I didn’t use the lock I used API endpoint. Then I need to get the user info using the token. I used `https://auth0_domain/userinfo` endpoint for this. Using Postman it’s working fine but in my project it always sending 401 (Unauthorized) error. Below is my code. I tried everything on the internet

```
let url = "https://auth0_domain/userinfo";
  let headers = new Headers({'Authorization': 'Bearer ' + this.getToken()});
  return this.http.get(url, {headers})
  .map((res: Response) => res.json())
  .subscribe(res => console.log('res'));

```

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 20, 2017, 6:23pm UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/2 "2017-06-20T18:23:22Z")

</div>

The information you provided is not sufficient to provide a definitive answer. You should check the following answer to a similar question to see if it might apply to your situation.

[The /userinfo endpoint returns 401 (Unauthorized)](http://community.auth0.com/answers/575/view)

* * *

Have in mind that the endpoint in question needs to be called with an access token and not with an ID token. In addition, if you can make it work in Postman, hardcode the token that works in your Angular application as that will let you discover if the source of the problem is token related or the way the application is performing the request.

---

<div class="post-metadata">

**Author:** ![wajira000](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wajira000](https://community.auth0.com/u/wajira000)\
**Post date:** [June 20, 2017, 7:56pm UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/3 "2017-06-20T19:56:19Z")

</div>

Thanks for the reply. I’m passing the access token not the ID token. to me it seems like header is not passing. I tried it without any headers and still get the same error. I tried to hard code the token and still not working.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 20, 2017, 10:35pm UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/4 "2017-06-20T22:35:58Z")

</div>

Yeah, your suggestion would indeed explain it. Try to review the request in the browser tools or any other HTTP capturing tool.

---

<div class="post-metadata">

**Author:** ![wajira000](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wajira000](https://community.auth0.com/u/wajira000)\
**Post date:** [June 21, 2017, 11:50am UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/5 "2017-06-21T11:50:04Z")

</div>

I found the problem. When I’m passing the token it comes with extra pair of quotations.  
“Bearer “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1N…””  
I used JSON.parse() and now it’s working. I hope this will help to someone who has the same problem. Thank You

---

<div class="post-metadata">

**Author:** ![wajira000](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wajira000](https://community.auth0.com/u/wajira000)\
**Post date:** [June 21, 2017, 11:50am UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/6 "2017-06-21T11:50:04Z")

</div>

I found the problem. When I’m passing the token it comes with extra pair of quotations.  
“Bearer “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1N…””  
I used JSON.parse() and now it’s working. I hope this will help to someone who has the same problem. Thank You

---

<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:54am UTC](https://community.auth0.com/t/get-user-info-using-authentication-api/7153/7 "2018-03-02T05:54:47Z")

</div>


