getAccessToken() returns encrypted token

  • Which SDK this is regarding:@auth0/nextjs-auth0”: “1.6.1”
  • Platform Version: e.g. Node v14.17.5

Using the examples from

and How to Authenticate with Next.js and Auth0: A Guide for Every Deployment Model

I am able to setup a nextjs/react app, sign into auth0 and get tokens back.
The issue I am having is when I call “getAccessToken()” in the api layer, the token returned seems to be encrypted (or at least not readable)
for example,


Some code in pages/api/user.js

import { getAccessToken, withApiAuthRequired } from ‘@auth0/nextjs-auth0’;

export default withApiAuthRequired(async function users(req, res) {
console.log(“getting users …”)
try {
const { accessToken } = await getAccessToken(req, res);
console.log(“with access token …”, accessToken)
const response = await fetch(, {
headers: {
Authorization: Bearer ${accessToken},
‘Content-Type’: ‘application/json’
method: ‘GET’
console.log(‘getting json …’, response.status)
let json = await response.json();
console.log(“json”, json);
} catch(error) {
res.status(error.status || 500).end(error.message)

and then I attempt to call that with client side code in pages/users.js

import Link from ‘next/link’
import useSWR from ‘swr’
import { withPageAuthRequired } from ‘@auth0/nextjs-auth0’

const fetcher = url => fetch(url).then(r => r.json())

const Users = () => {
const { users, error } = useSWR(’/api/user’, fetcher)
if (!Array.isArray(users)) {
return (

Users (no array)


return (
        <Link href="/">Home</Link><br />
            { => (<li key={d.userId}>{} {d.userId}</li>))}

export const getServerSideProps = withPageAuthRequired();
export default Users

Hey there!

In order to handle that most effectively can I ask you to raise it as a GitHub issue in the SDK repo so we can have that addressed directly with the SDK maintainers? Once you have a link to it make sure to share it here with us so we can ping them.

1 Like

Hey there!

Did you have a chance to open it?

Sorry for the delay – and the skimpy description – See I am getting encrpted cookie when asking for access token · Issue #537 · auth0/nextjs-auth0 · GitHub
And thanks for your follow up

1 Like

No worries!

Thanks for creating the issue, I’ll ping the repo maintainers in a few minutes!