# Err\_callback\_handler\_failure

**URL:** <https://community.auth0.com/t/err-callback-handler-failure/114231>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [August 22, 2023, 4:03pm UTC](https://community.auth0.com/t/err-callback-handler-failure/114231 "2023-08-22T16:03:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hitesh.khatri](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hitesh.khatri/32/50123_2.png) [@hitesh.khatri](https://community.auth0.com/u/hitesh.khatri)\
**Post date:** [August 22, 2023, 4:03pm UTC](https://community.auth0.com/t/err-callback-handler-failure/114231/1 "2023-08-22T16:03:15Z")

</div>

I am trying to create a simple/sample NextJs app with OAuth login  
I downloaded the code provided by the dashboard whilst creating firs sample APP using NextJs

I configured and copied environment variables mentioned exactly in `https://auth0.com/docs/quickstart/webapp/nextjs/interactive` article.

I ran `npm install` `npm run dev` and started the app.

my NextJs Application uses `pages` directory and `/api/auth/[auth0].ts`, api handler is simply

import {handleAuth} from “@auth0/nextjs-auth0”;

export default handleAuth();

when I click Login, I get redirected to Auth0 screen for signin/SignUp.

It then redirects me to my application on

[http://localhost:3000/api/auth/callback?code=tCpAwy1x5umkry1TQ\_IQMq9-wiDuwIToM8Lq0e23FdHAI&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9](http://localhost:3000/api/auth/callback?code=tCpAwy1x5umkry1TQ_IQMq9-wiDuwIToM8Lq0e23FdHAI&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9)

with following error on nextJs Server console!!

CallbackHandlerError: Callback handler failed. CAUSE: Missing state cookie from login request (check login URL, callback URL and cookie config).  
at CallbackHandlerError.AuthError [as constructor] (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/@auth0/nextjs-auth0/dist/utils/errors.js:34:16)  
at CallbackHandlerError.HandlerError [as constructor] (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/@auth0/nextjs-auth0/dist/utils/errors.js:110:23)  
at new CallbackHandlerError (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/@auth0/nextjs-auth0/dist/utils/errors.js:138:28)  
at /Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/@auth0/nextjs-auth0/dist/handlers/callback.js:42:31  
at step (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/tslib/tslib.js:195:27)  
at Object.throw (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/tslib/tslib.js:176:57)  
at rejected (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/tslib/tslib.js:167:69)  
at process.processTicksAndRejections (node:internal/process/task\_queues:95:5) {  
code: ‘ERR\_CALLBACK\_HANDLER\_FAILURE’,  
cause: MissingStateCookieError: Missing state cookie from login request (check login URL, callback URL and cookie config).  
at new MissingStateCookieError (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/@auth0/nextjs-auth0/dist/auth0-session/utils/errors.js:39:16)  
at /Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/@auth0/nextjs-auth0/dist/auth0-session/handlers/callback.js:30:63  
at step (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/tslib/tslib.js:195:27)  
at Object.next (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/tslib/tslib.js:176:57)  
at fulfilled (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node\_modules/tslib/tslib.js:166:62)  
at process.processTicksAndRejections (node:internal/process/task\_queues:95:5) {  
expose: true,  
statusCode: 400,  
status: 400  
},  
status: 400  
}

I have tried to upgrade / downgrade Auth0 version(s) …but nothing works!!

This topic has been discussed here multiple times … but everyone’s causes seems to be different!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [August 22, 2023, 7:49pm UTC](https://community.auth0.com/t/err-callback-handler-failure/114231/3 "2023-08-22T19:49:13Z")

</div>

Hi @hitesh.khatri,

It looks like the `state` parameter was not passed in the login request. This is also justified by the response URL: [http://localhost:3000/api/auth/callback?code=tCpAwy1x5umkry1TQ\_IQMq9-wiDuwIToM8Lq0e23FdHAI&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9](http://localhost:3000/api/auth/callback?code=tCpAwy1x5umkry1TQ_IQMq9-wiDuwIToM8Lq0e23FdHAI&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9)

You should expect something like the following when passing the `state` parameter in the `/authorize` request:  
[http://localhost:3000/api/auth/callback?code=tCpAwy1x5umkry1TQ\_IQMq9-wiDuwIToM8Lq0e23FdHAI&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9&state=yourState](http://localhost:3000/api/auth/callback?code=tCpAwy1x5umkry1TQ_IQMq9-wiDuwIToM8Lq0e23FdHAI&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9&state=yourState)

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![james.sherry](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.sherry/32/28260_2.png) [@james.sherry](https://community.auth0.com/u/james.sherry)\
**Post date:** [September 1, 2023, 2:23pm UTC](https://community.auth0.com/t/err-callback-handler-failure/114231/4 "2023-09-01T14:23:56Z")

</div>

Hi @hitesh.khatri ,  
What was the fix you implemented? There’s quite a few of us stuck with this problem…

---

<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:** [September 15, 2023, 2:24pm UTC](https://community.auth0.com/t/err-callback-handler-failure/114231/5 "2023-09-15T14:24:40Z")

</div>

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