# Access user\_metadata from a SPA

**URL:** <https://community.auth0.com/t/access-user-metadata-from-a-spa/116629>\
**Category:** Get Help\
**Tags:** ticket-management, support-center\
**Created:** [September 19, 2023, 4:17pm UTC](https://community.auth0.com/t/access-user-metadata-from-a-spa/116629 "2023-09-19T16:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandersen](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gandersen/32/51000_2.png) [@gandersen](https://community.auth0.com/u/gandersen)\
**Post date:** [September 19, 2023, 4:17pm UTC](https://community.auth0.com/t/access-user-metadata-from-a-spa/116629/1 "2023-09-19T16:17:09Z")

</div>

Hello,

I have been struggling a great deal to understand how to access the user\_metadata.

The use case is as follows:

After a user has signed up to the system, we wish to retrieve additional information from the user. To solve this we have added a flag in the user\_metadata in the “Pre User Registration” flow with the following value:

{  
“post\_registration\_pending”: true  
}

in order to create business logic in the frontend to display a form for the user to input further data not included in the sign up process.

From what I could read from the [docs](https://auth0.com/docs/manage-users/user-accounts/metadata), I should be able to retrieve the metadata via the Management API at the endpoint "/api/v2/users/{id} from the client

I do however get 401 Unauthorised.

I could read from [this post](https://community.auth0.com/t/getting-unauthorized-when-trying-to-fetch-user-profile/116141), that in order to use the Management API I needed ask Auth0 for an access token.

When I access the go the the Auth0 dashboard and go to Applications/API/Test I do get a successful access\_token, however, when I try to do the same thing in the client I get a CORS error.

What can I do here? Am I even on the right track in terms of achieving what should be a pretty simple functionality?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 19, 2023, 9:02pm UTC](https://community.auth0.com/t/access-user-metadata-from-a-spa/116629/3 "2023-09-19T21:02:04Z")

</div>

Hi @gandersen,

Yes, while it is possible to access the Management API from a SPA, they are issued in the context of the user who is currently signed in to Auth0.

In this case, I recommend following our [Get Management API Access Tokens for Single-Page Applications](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications) documentation for more information.

Alternatively, you could append the user\_metadata as a [custom claim to the access token](https://community.auth0.com/t/adding-custom-claims-to-tokens/84590).

Please let me know if you have any questions.

Thanks,  
Rueben

---

<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:** [October 3, 2023, 9:03pm UTC](https://community.auth0.com/t/access-user-metadata-from-a-spa/116629/4 "2023-10-03T21:03:01Z")

</div>

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