# Why my token has 2 dots (..) in it?

**URL:** <https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186>\
**Category:** JWT.io\
**Created:** [May 4, 2023, 6:00pm UTC](https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186 "2023-05-04T18:00:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominic.bouchard.355](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dominic.bouchard.355/32/46889_2.png) [@dominic.bouchard.355](https://community.auth0.com/u/dominic.bouchard.355)\
**Post date:** [May 4, 2023, 6:00pm UTC](https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186/1 "2023-05-04T18:00:55Z")

</div>

I’m using apollo server, Auth0 and jwt/jwksClient for my app authentication.

When I look at the token my front end is sending to the back-end it has 2 dots inside which indicates its only signed. When decrypting in the back-end, jwt tells me the token is malformed.

I don’t know why its giving me this result. Any help?

Token:

```auto
eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaXNzIjoiaHR0cHM6Ly9kZXYteWpkczdzMHcudXMuYXV0aDAuY29tLyJ9..-If5niecxqNWV7WB.VDV1LEr9TUkijSNg9-lN7trsW1ymaFxSOcVB6uDPFBofjtAF_cDXPzwg1Q7d0RtfIi6nXzwNExsd9TNyyW4dOmPYlrdrd80NYGeof7VuPxU0RdItqjj3gydAGodY_C3iT10EekryAzuETF-O8BSBf4aS7NPISHC34TJYg_dTw4ZwaQBj_ry0fCn2RFTBU8yQlEFf7DxrS0TCC3P4FMDys6JDEyKm3_2UuAyTHBY0ZZLB_5qpEmAZRH5mcs5KSnlYPd-QjrHHLCEFAq860rUyYV3HgXCm1zd_9ELX6z5ODdrQaSKBKHLxsu4iLxXDXk4Ec4U.0AGGCtcmx4KOYrJsKwAEpw

```

Front end code:

```plaintext
import { ApolloClient, InMemoryCache, ApolloProvider, HttpLink } from '@apollo/client';
import { setContext } from '@apollo/client/link/context';
import { useAuth0 } from '@auth0/auth0-react';

import { config } from '../../env';

function ApolloWrapper({ children }) {
  const { isAuthenticated, getAccessTokenSilently } = useAuth0();
  const [bearerToken, setBearerToken] = useState('');

  useEffect(() => {
    const getToken = async () => {
      try {
        const token = isAuthenticated ? await getAccessTokenSilently() : '';
        setBearerToken(token);
        console.log(token);
      } catch (err) {
        console.log('Failed to fetch token', err);
      }
    };
    if (isAuthenticated) {
      getToken();
    } else {
      setBearerToken('');
    }
  }, [getAccessTokenSilently, isAuthenticated]);

  const httpLink = new HttpLink({ uri: config.GRAPHQL_URI });

  const authLink = setContext((_, { headers, ...rest }) => {
    if (!bearerToken) return { headers, ...rest };
    return {
      ...rest,
      headers: {
        ...headers,
        authorization: `Bearer ${bearerToken}`,
      },
    };
  });

  const client = new ApolloClient({
    cache: new InMemoryCache(),
    link: authLink.concat(httpLink),
  });

  return <ApolloProvider client={client}>{children}</ApolloProvider>;
}

export default ApolloWrapper;

```

---

<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:** [May 4, 2023, 10:06pm UTC](https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186/3 "2023-05-04T22:06:32Z")

</div>

Hi there @dominic.bouchard.355 welcome to the community!

It looks like you’re attempting to use an [opaque access token](https://auth0.com/docs/secure/tokens/access-tokens#opaque-access-tokens) (lacking an audience) - Which can only be used against the [userinfo](https://auth0.com/docs/api/authentication?shell#user-profile) endpoint. You’ll need to use [authorizationParams](https://auth0.github.io/auth0-react/interfaces/AuthorizationParams.html) on your front end to pass an `audience` param.

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

Hope this helps!

---

<div class="post-metadata">

**Author:** ![dominic.bouchard.355](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dominic.bouchard.355/32/46889_2.png) [@dominic.bouchard.355](https://community.auth0.com/u/dominic.bouchard.355)\
**Post date:** [May 4, 2023, 11:56pm UTC](https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186/4 "2023-05-04T23:56:53Z")

</div>

Hey, thank you! I don’t know why all the examples I saw online were not using the autorizationParams and still working??!

Anyhow, I was on this problem for the last day and half. Here’s my updated code 🙂

```plaintext
import { ApolloClient, InMemoryCache, ApolloProvider, HttpLink } from '@apollo/client';
import { setContext } from '@apollo/client/link/context';
import { useAuth0 } from '@auth0/auth0-react';

import { config } from '../../env';

function ApolloWrapper({ children }) {
  const { isAuthenticated, getAccessTokenSilently } = useAuth0();
  const [bearerToken, setBearerToken] = useState('');

  useEffect(() => {
    const getToken = async () => {
      try {
        const options = { authorizationParams: { audience: config.REACT_APP_AUDIENCE } }; //modification here
        console.log(options);
        const token = isAuthenticated ? await getAccessTokenSilently(options) : '';
        setBearerToken(token);
        console.log(token);
      } catch (err) {
        console.log('Failed to fetch token', err);
      }
    };
    if (isAuthenticated) {
      getToken();
    } else {
      setBearerToken('');
    }
  }, [getAccessTokenSilently, isAuthenticated]);

  const httpLink = new HttpLink({ uri: config.GRAPHQL_URI });

  const authLink = setContext((_, { headers, ...rest }) => {
    if (!bearerToken) return { headers, ...rest };
    return {
      ...rest,
      headers: {
        ...headers,
        authorization: `Bearer ${bearerToken}`,
      },
    };
  });

  const client = new ApolloClient({
    cache: new InMemoryCache(),
    link: authLink.concat(httpLink),
  });

  return <ApolloProvider client={client}>{children}</ApolloProvider>;
}

export default ApolloWrapper;

```

---

<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:** [May 9, 2023, 3:23pm UTC](https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186/5 "2023-05-09T15:23:18Z")

</div>

No problem, glad that’s sorted! Thanks for sharing your updated code 🙂

---

<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:** [May 23, 2023, 3:23pm UTC](https://community.auth0.com/t/why-my-token-has-2-dots-in-it/106186/6 "2023-05-23T15:23:26Z")

</div>

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