# Call Management API from a SPA - Documentation Clarification

**URL:** <https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351>\
**Category:** Get Help\
**Tags:** clients, management-api\
**Created:** [October 11, 2023, 6:39pm UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351 "2023-10-11T18:39:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![niall](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@niall](https://community.auth0.com/u/niall)\
**Post date:** [October 11, 2023, 6:39pm UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351/1 "2023-10-11T18:39:51Z")

</div>

Hi

I’m trying to get a management token from a SPA. I have worked with a few projects where I can get a token either in an Action/Rule or a backend, but the SPA element is new to me. This is part of an account linking function in the SPA. First task. get a management API token.

The document here is

> **[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)**
>
> Learn about available scopes and endpoints for Management API tokens for Single-page Applications (SPAs).

It states you get a management API token by triggering a request to the /authorize endpoint. The document also states that you need to include the Management API audience value, and the relevant scopes in the request.

What I’m missing is whether this request to /authorize is part of the initial OIDC with PKCE flow to authenticate the user, or a secondary request to /authorize for an already authenticated user.

So do I tack an audience value and the Management API scopes I need in addition to the standard OIDC parameters for a SPA, or log the user in first and then make a secondary call to the /authorize end point with the audience and scopes for the management API ?

I’ve tried the former, but don’t get a JWT back, so looking for a steer to support the docs. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 11, 2023, 9:22pm UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351/3 "2023-10-11T21:22:20Z")

</div>

Hey @niall!

Thanks for the detailed description - I guess first and foremost it would be good to know what exactly you are looking to accomplish via the Management API. I say this because any Management API access token you get via a SPA is going to be fairly [limited](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications#available-scopes-and-endpoints) and may not suffice for your use case.

Ideally, the getting and using of Management API access tokens should be handled by a backend as outlined in the following FAQ:

[https://community.auth0.com/t/how-can-i-enable-users-to-change-their-email-address-from-a-spa-or-native-app/44064](https://community.auth0.com/t/how-can-i-enable-users-to-change-their-email-address-from-a-spa-or-native-app/44064)

If you’re interested, here is an example using our [Node Management Client](https://github.com/tyfrth/auth0-react-samples-proxy/blob/master/Sample-01/api-server.js) paired with our React sample app.

---

<div class="post-metadata">

**Author:** ![niall](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@niall](https://community.auth0.com/u/niall)\
**Post date:** [October 12, 2023, 9:46am UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351/4 "2023-10-12T09:46:12Z")

</div>

Hi Tyf

The full requirement is this. Client Side account linking. This document describes exactly the requirement we are looking for.

> **[User-Initiated Account Linking: Client-Side Implementation](https://auth0.com/docs/manage-users/user-accounts/user-account-linking/user-initiated-account-linking-client-side-implementation)**
>
> Learn how to provide a client-side UI that allows users to authenticate to their other accounts and link these to their primary account using a SPA.

It talks to being able to get an API token for the management API for the SPA, and I actually have this working now. To answer my own question, you need to add the relevant Management API scopes and the management API audience to your initial call to /authorize endpoint when authenticating the user. Auth0 then returns an access token ( JWT ) that can be used to make management API calls.

However, that document also calls out the limited scopes available for an access token for the management API issued to a SPA. I do not think I can leverage the Linking API with the scopes available to me. That’s the next step, but it would make documentation misleading.

Unfortunately the requirement is for this to be enabled in a SPA. No backend, which would be my preferred route and much simpler and more secure.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 20, 2023, 12:35am UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351/5 "2023-10-20T00:35:49Z")

</div>

Hey @niall thanks for following up and I apologize for the delayed response.

> [@niall](#):
>
> However, that document also calls out the limited scopes available for an access token for the management API issued to a SPA. I do not think I can leverage the Linking API with the scopes available to me. That’s the next step, but it would make documentation misleading.
> 
> Unfortunately the requirement is for this to be enabled in a SPA. No backend, which would be my preferred route and much simpler and more secure.

Thanks for clarifying - Unfortunately due to security reasons there’s no way around the limited scopes available to a client-side management api token 😕

---

<div class="post-metadata">

**Author:** ![niall](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@niall](https://community.auth0.com/u/niall)\
**Post date:** [October 20, 2023, 8:39am UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351/6 "2023-10-20T08:39:27Z")

</div>

Thanks Ty. Appreciate you taking the time to get back to me.  
Those docs definitely need tidying up then. The natural flow from the account linking documents takes you to client side management API usage, which is a dead end for a SPA.

---

<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:** [November 3, 2023, 8:40am UTC](https://community.auth0.com/t/call-management-api-from-a-spa-documentation-clarification/118351/7 "2023-11-03T08:40:21Z")

</div>

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