# Using access\_token with external APIs

**URL:** <https://community.auth0.com/t/using-access-token-with-external-apis/60637>\
**Category:** Get Help\
**Tags:** nextjs\
**Created:** [April 6, 2021, 2:54pm UTC](https://community.auth0.com/t/using-access-token-with-external-apis/60637 "2021-04-06T14:54:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![masaez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/masaez/32/25064_2.png) [@masaez](https://community.auth0.com/u/masaez)\
**Post date:** [April 6, 2021, 2:54pm UTC](https://community.auth0.com/t/using-access-token-with-external-apis/60637/1 "2021-04-06T14:54:16Z")

</div>

I am working on a nextjs app that needs to call an external API as described in [How to Authenticate with Next.js and Auth0: A Guide for Every Deployment Model](https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/)

 ![Calling an external API](https://global.discourse-cdn.com/auth0/original/3X/0/1/01d3d14adfdcc0b2289f2424a1fcd1c29a5359a3.png)

The access token that I am receiving does not seem to be a JWT valid token, and I am not sure if its really an opaque token either (it has 32 characters). I tried validating the token against the /userinfo endpoint, but I am getting a 401.

Would you mind sharing a sample on how the external BillingAPI mentioned in the next js tutorial would validate the received token?

Thanks!

---

<div class="post-metadata">

**Author:** ![masaez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/masaez/32/25064_2.png) [@masaez](https://community.auth0.com/u/masaez)\
**Post date:** [April 6, 2021, 5:00pm UTC](https://community.auth0.com/t/using-access-token-with-external-apis/60637/2 "2021-04-06T17:00:59Z")

</div>

Alright, I finally got a JWT by specifying the audience while init auth0 in Next.JS. Something really strange: I was previously doing that on the .env file specifying AUTH0\_AUDIENCE but for some weird reason it was not working, and only went through when I manually sent it on my initAuth0 function call.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 8, 2021, 10:03am UTC](https://community.auth0.com/t/using-access-token-with-external-apis/60637/3 "2021-04-08T10:03:23Z")

</div>

Glad you have it working now and thanks for sharing with the rest of 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:** [April 23, 2021, 10:03am UTC](https://community.auth0.com/t/using-access-token-with-external-apis/60637/4 "2021-04-23T10:03:55Z")

</div>

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