Next app deployed on vercel - [CallbackHandlerError]: Callback handler failed. CAUSE: access_denied (Unauthorized)

I recently deployed my Next app-router app to Vercel. For some reason, I get an error returned in the auth callback. It works fine locally. I tried logging into an existing account and creating a new one, both fail.

I’ve been following the instructions here:

a [CallbackHandlerError]: Callback handler failed. CAUSE: access_denied (Unauthorized)
    at /var/task/.next/server/chunks/99.js:1:39181
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /var/task/.next/server/chunks/99.js:1:36639
    ... 4 lines matching cause stack trace ...
    at async en.responseCache.get.routeKind (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:1026)
    at async r6.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:508)
    at async r6.renderPageComponent (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:5121) {
  code: 'ERR_CALLBACK_HANDLER_FAILURE',
  cause: o [Error]: access_denied (Unauthorized)
      at h.callback (/var/task/.next/server/chunks/99.js:1:3769)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async /var/task/.next/server/chunks/99.js:1:13387
      at async /var/task/.next/server/chunks/99.js:1:39131
      at async /var/task/.next/server/chunks/99.js:1:36639
      at async /var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36258
      at async eR.execute (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:26874)
      at async eR.handle (/var/task/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37512)
      at async es (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:25465)
      at async en.responseCache.get.routeKind (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:1026) {
    error: 'access_denied',
    errorDescription: 'Unauthorized',
    status: 400,
    statusCode: 400,
    openIdState: { returnTo: 'https://aa-next.vercel.app/' }
  },
  status: 400
}

Hi @bryso

Welcome to the Auth0 Community!

Thank you for posting your question. As your application is working properly locally, the issue may be connected to the Vercel caching mechanism.

We have an excellent Knowledge Solution regarding this issue, which you can find here

Thanks
Dawid

Thanks, I tried the suggestions for disabling cache in the Next docs, but it didn’t work for me :confused:

I also was able to log in fine when I was originally deployed to a shared-hosting provider, which leads me to believe this wasn’t a caching issue.

Hi @bryso

Ok, so we’ll dig deeper. Can you check if your clientSecret is correct for the clientId?

You can also try the latest integration between Auth0 and Vercel → https://vercel.com/integrations/auth0

Thanks
Dawid

Ok I had some time to circle back to this. Apparently I was using the wrong clientId / secret combination somehow. It now seems to be working. Thanks!

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