# Get user profile data using pure javascript?

**URL:** <https://devforum.okta.com/t/get-user-profile-data-using-pure-javascript/4130>\
**Category:** Questions\
**Created:** [February 6, 2019, 6:57pm UTC](https://devforum.okta.com/t/get-user-profile-data-using-pure-javascript/4130 "2019-02-06T18:57:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@shane](https://devforum.okta.com/u/shane)\
**Post date:** [February 6, 2019, 6:57pm UTC](https://devforum.okta.com/t/get-user-profile-data-using-pure-javascript/4130/1 "2019-02-06T18:57:15Z")

</div>

Hello, I’m creating a SPA using pure javascript. I’m curious the recommended way to get user profile data from Okta? I would like the complete profile and not just the email. Because I have a pure javascript application, I am using the Okta Sign-in widget. Once they have logged in I store the access token, which I believe is a Bearer token.

I am trying to use this token to call the “oauth2/default/v1/userinfo” endpoint. However, I am getting Cors errors, even though I have all of my set properly in my Okta trusted origins. I’m assuming this is because this endpoint does not support Cors?

I then tried to call the " /api/v1/users/me" to get the users profile. However, I am unable to call this API with the Bearer token returned by the sign-in widget.

How do I trade in my bearer token for an API token, so I can call the “api/v1/users/me”? Keep in mind this is a pure javascript app so I can not store a client secret anywhere?

Or am I taking the wrong approach? Is there an easier way to get the profile data in a pure javascript app?

---

<div class="post-metadata">

**Author:** ![dragos](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dragos/32/1313_2.png) [@dragos](https://devforum.okta.com/u/dragos)\
**Post date:** [February 20, 2019, 1:48pm UTC](https://devforum.okta.com/t/get-user-profile-data-using-pure-javascript/4130/2 "2019-02-20T13:48:10Z")

</div>

Hi @shane

You can use /api/v1/users/${userId] endpoint as described [here](https://developer.okta.com/docs/api/resources/users#get-user) to retrieve a user’s profile. This endpoint can be called through CORS. You can find [here](https://developer.okta.com/docs/api/getting_started/enabling_cors) the steps and JavaScript & jQuery examples on how to access the endpoint.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 17, 2024, 7:41pm UTC](https://devforum.okta.com/t/get-user-profile-data-using-pure-javascript/4130/3 "2024-01-17T19:41:29Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
