# Get JWT token for logged in user, without a secret?

**URL:** <https://community.auth0.com/t/get-jwt-token-for-logged-in-user-without-a-secret/101263>\
**Category:** JWT.io\
**Tags:** jwt, access-token, auth0\
**Created:** [February 24, 2023, 9:37pm UTC](https://community.auth0.com/t/get-jwt-token-for-logged-in-user-without-a-secret/101263 "2023-02-24T21:37:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StuStu](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@StuStu](https://community.auth0.com/u/StuStu)\
**Post date:** [February 24, 2023, 9:37pm UTC](https://community.auth0.com/t/get-jwt-token-for-logged-in-user-without-a-secret/101263/1 "2023-02-24T21:37:50Z")

</div>

I have a Quasar (Vue 3) SPA, that authenticates with Auth0. This works great!

[SPA] loginWithRedirect() → [Auth0] → Logged in.

I have now added an API (PostgREST) into the mix. PostgREST is a REST API wrapper for PostgreSQL, and allows for authentication using JWT.

I can manually create a JWT and add it to the SPA, this works, it authenticates with the PostgREST API. Question now is, how do I get an actual JWT (not hardcoded) for this user in my SPA? I was thinking that Auth0 could provide me with a JWT token, after having succesfully been authenticated. However, it seems that it requires an Auth0 secret to request a JWT?

This says I need a client secret to request a JWT token:

> **[Get Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/get-access-tokens)**
>
> Learn how to request Access Tokens using the Authorize endpoint when authenticating users and include the target audience and scope of access requested by the app and granted by the user.

This won’t do, as an SPA is basically client-side code, and I cannot safely store the secret in the SPA code.

Am I missing something or is this a dead end?  
Much appreciated!

---

<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:** [February 25, 2023, 1:04am UTC](https://community.auth0.com/t/get-jwt-token-for-logged-in-user-without-a-secret/101263/3 "2023-02-25T01:04:18Z")

</div>

Hello there @StuStu welcome to the community!

> [@StuStu](#):
>
> I can manually create a JWT and add it to the SPA, this works, it authenticates with the PostgREST API. Question now is, how do I get an actual JWT (not hardcoded) for this user in my SPA? I was thinking that Auth0 could provide me with a JWT token, after having succesfully been authenticated. However, it seems that it requires an Auth0 secret to request a JWT?

You’re on the right track in thinking that Auth0 can provide a user with a JWT(s) upon successful authentication/authorization. The Vue SDK should take care of this for you - I definitely recommend checking out our sample app [here](https://github.com/auth0-samples/auth0-vue-samples). You may find the [quickstart](https://auth0.com/docs/quickstart/spa/vuejs/01-login) and this [documentation](https://developer.auth0.com/resources/guides/spa/vue/basic-authentication/javascript-options-api?integrate-vue-js-with-an-api-server#integrate-vue-js-with-an-api-server) helpful as well 😄

> [@StuStu](#):
>
> This won’t do, as an SPA is basically client-side code, and I cannot safely store the secret in the SPA code.

That’s correct, the Access Tokens the documentation you linked is referring to to [Management API](https://auth0.com/docs/api/management/v2) Access tokens which can perform tenant related actions. An access token returned by the Vue SDK or in any SPA SDK will be specific to the user, and is typically verified by and used against an API (your API). You may find our [architecture scenarios](https://auth0.com/docs/get-started/architecture-scenarios) documentation helpful as well.

Hope this helps!

---

<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 11, 2023, 10:20am UTC](https://community.auth0.com/t/get-jwt-token-for-logged-in-user-without-a-secret/101263/5 "2023-03-11T10:20:11Z")

</div>

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