# Expo Implementation. Invalid access\_token

**URL:** <https://community.auth0.com/t/expo-implementation-invalid-access-token/90204>\
**Category:** Get Help\
**Tags:** access\_token, spa, jwt, api, expo\
**Created:** [September 8, 2022, 6:06am UTC](https://community.auth0.com/t/expo-implementation-invalid-access-token/90204 "2022-09-08T06:06:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![forestman27](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/forestman27/32/39788_2.png) [@forestman27](https://community.auth0.com/u/forestman27)\
**Post date:** [September 8, 2022, 6:06am UTC](https://community.auth0.com/t/expo-implementation-invalid-access-token/90204/1 "2022-09-08T06:06:28Z")

</div>

The id\_token I get back seems to be working great. I can decode it or send it to my api however I believe using it in the authorization header is a bad practice.

The problem is the access\_token I get back is invalid. I get this when trying to decode it →

> [InvalidTokenError: Invalid token specified: JSON Parse error: Unexpected EOF]  
> Here is the access\_token  
> ![Screen Shot 2022-09-07 at 10.50.03 PM](https://global.discourse-cdn.com/auth0/original/3X/5/f/5fb835fe8aea68053d075776b5d1b43c01144702.png)  
> Note: it is missing the payload

Here is my code:

```auto
const auth0ClientId = "dKqbEwC ****************......";
const authorizationEndpoint = "https://dev-39brjlao.us.auth0.com/authorize";

const useProxy = Platform.select({ web: false, default: true });
const redirectUri = AuthSession.makeRedirectUri({ useProxy });

export default function Auth0() {
  const [name, setName] = useState(null);
  const [request, result, promptAsync] = AuthSession.useAuthRequest(
    {
      redirectUri,
      clientId: auth0ClientId,
      responseType: "token id_token",
      scopes: ["openid", "profile"],
      extraParams: {
        nonce: "nonce",
      },
    },
    { authorizationEndpoint }
  );
  console.log(`Redirect URL: ${redirectUri}`);
  useEffect(() => {
    if (result) {
      if (result.error) {
        Alert.alert(
          "Authentication error",
          result.params.error_description || "something went wrong"
        );
        return;
      }
      if (result.type === "success") {
        const id_token = result.params.id_token;
        const access_token = result.params.access_token;
        const decoded = jwtDecode(id_token);
        const { name } = decoded;        
        SecureStore.setItemAsync('id_token', id_token);
        SecureStore.setItemAsync('access_token', access_token);
        setName(name);
      }
    }
  }, [result]);

```

---

<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:** [September 9, 2022, 1:09am UTC](https://community.auth0.com/t/expo-implementation-invalid-access-token/90204/3 "2022-09-09T01:09:36Z")

</div>

Hey there @forestman27 welcome to the community!

> [@forestman27](#):
>
> The problem is the access\_token I get back is invalid. I get this when trying to decode it →

The issue you are describing is typically due to the fact that an opaque access token is returned - This occurs when there is no `audience` param passed in the authorize request. See the following FAQ for more detail:

[https://community.auth0.com/t/why-is-my-access-token-not-a-jwt-opaque-token/31028](https://community.auth0.com/t/why-is-my-access-token-not-a-jwt-opaque-token/31028)

---

<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:** [September 24, 2022, 1:10am UTC](https://community.auth0.com/t/expo-implementation-invalid-access-token/90204/4 "2022-09-24T01:10:30Z")

</div>

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