# JWT malformed from Vue SPA using auth0-spa-js library

**URL:** <https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643>\
**Category:** Get Help\
**Tags:** express-openid-connect, sdks-quickstarts\
**Created:** [November 17, 2022, 5:53pm UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643 "2022-11-17T17:53:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kristen-s](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kristen-s/32/41337_2.png) [@kristen-s](https://community.auth0.com/u/kristen-s)\
**Post date:** [November 17, 2022, 5:53pm UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/1 "2022-11-17T17:53:03Z")

</div>

The JWT submitted from our client app to Express server is malformed. When I paste it into the debugger at [jwt.io](http://jwt.io), the payload is empty because the first dot-separation is a double dot. The token is 490 chars total.

```auto
~header~..~signature? but there's another '.' character 16 chars in~

```

The client app uses Vue 2 and Typescript. Two examples used to develop the Auth0 wrapper are:

1. Primarily from [Auth0 documentation for Vue 2](https://github.com/auth0/auth0-vue/blob/main/tutorial/vue2-login.md).
2. Secondarily from [another page](https://blog.risingstack.com/auth0-vue-typescript-quickstart-docs/) for Typescript types.

From another question here, I found others have said to add an audience. I would link to it but the community guidelines have me limited.  
They weren’t specific as to where to add the audience. So, we tried to add audience to two different methods with no change to the resulting token. Methods below are both from the @auth0/auth0-spa-js library.

Options fed into createAuth0Client() look like this:

```auto
const options: Auth0ClientOptions = {
          domain: <tenant>.us.auth0.com,
          clientId: <clientId>,
          authorizationParams: {
              redirect_uri: http://localhost:<port>/,
              audience: https://<domain>.net/,
          }
      };

```

Options fed into getTokenSilently() look like this:

```auto
const options: GetTokenSilentlyOptions = {
          authorizationParams: {
              audience: https://<domain>.net/
          }
      };

```

Do we need to put the audience value somewhere else?

Has anyone else successfully implemented the Vue2 example but found they needed to make a critical change compared to the example?

---

<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:** [November 17, 2022, 9:28pm UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/2 "2022-11-17T21:28:55Z")

</div>

Hey there @kristen-s welcome to the community, and thanks for the detailed description of what you’re experiencing 😄

Looking at our quickstart for [calling an API](https://auth0.com/docs/quickstart/spa/vuejs/02-calling-an-api#configuring-the-plugin) leads me to believe you’d want to add the audience to your `Auth0ClientOptions` like:

```auto
const options: Auth0ClientOptions = {
          domain: <tenant>.us.auth0.com,
          clientId: <clientId>,
          audience: <your_api_identifier>,
          authorizationParams: {
              redirect_uri: http://localhost:<port>/,
          }
      };

```

You are correct though in that you will need an audience in the context of using it against your Express server:

[https://community.auth0.com/t/what-is-the-audience/71414](https://community.auth0.com/t/what-is-the-audience/71414)

Keep us posted!

---

<div class="post-metadata">

**Author:** ![kristen-s](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kristen-s/32/41337_2.png) [@kristen-s](https://community.auth0.com/u/kristen-s)\
**Post date:** [November 18, 2022, 5:18pm UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/4 "2022-11-18T17:18:49Z")

</div>

Hi Tyf,

Thank you for your quick response. Unfortunately, moving the audience parameter as you suggested doesn’t make a difference in the token returned.

Any other ideas?

Thanks,  
Kristen

---

<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:** [November 19, 2022, 12:27am UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/5 "2022-11-19T00:27:04Z")

</div>

Hey @kristen-s no problem, happy to help where I can!

That’s interesting you’re still having an issue with the token being malformed, I don’t have any other ideas off the top of my head 🤔

Have you had a chance to walk through our [Vue samples](https://github.com/auth0-samples/auth0-vue-samples)? In particular, I’d be curious if you were to work through the bit regarding calling an API in particular, and compare that against your own code/environment. The `calling an API` sample is from the quickstart I linked previously.

---

<div class="post-metadata">

**Author:** ![kristen-s](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kristen-s/32/41337_2.png) [@kristen-s](https://community.auth0.com/u/kristen-s)\
**Post date:** [November 21, 2022, 3:19pm UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/6 "2022-11-21T15:19:42Z")

</div>

Tyf,

Thank you.

I went through that reference, and didn’t find any new information there specifically.

However, I did find my issue as I was double-checking everything. I had initially expected the environment variable for audience to only be needed on the express server side. So I did not prepend the variable name with ‘VUE\_APP\_’. That turned out to be my problem, as there was no value for my audience variable. It works now!

Hopefully this can help others who have a similar Vue setup.

---

<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:** [November 22, 2022, 4:32am UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/7 "2022-11-22T04:32:23Z")

</div>

Hey @kristen-s good to know you got it working, and thanks a bunch for following up with the community! 🚀

---

<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:** [December 6, 2022, 4:32am UTC](https://community.auth0.com/t/jwt-malformed-from-vue-spa-using-auth0-spa-js-library/94643/8 "2022-12-06T04:32:30Z")

</div>

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