Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent issue "checks.state argument is missing" #635

Closed
felixdasgupta opened this issue Apr 5, 2022 · 2 comments
Closed

Consistent issue "checks.state argument is missing" #635

felixdasgupta opened this issue Apr 5, 2022 · 2 comments
Labels
question Further information is requested

Comments

@felixdasgupta
Copy link

Description

I keep getting a checks.state argument is missing. All my variables, etc are setup just fine. Could this be a Heroku related issue? Using them to deploy.

This doesn't work in incognito either.

Reproduction

After login, this jumps to the callback page and then I see a blank page with checks.state argument is missing as the only text on the page.

Url is formed as so {path-to-site}.com/api/auth/callback?code={random-hash}&state={random-hash} where the random-hash are fully formed random alphanumeric strings.

Console says

Failed to load resource: the server responded with a status of 400 (Bad Request).  callback:1

This is my code under pages/api/auth/[...auth0.js]

import {
  handleAuth,
  handleLogin,
  handleCallback,
  handleLogout
} from "@auth0/nextjs-auth0";


// Check what is in this state? Why is this missing?
const afterCallback = (req, res, session, state) => {
  console.log("STATE", session, state);
  return session;
};

export default handleAuth({
  async login(req, res) {
    try {
      await handleLogin(req, res, {
        baseURL: process.env.HOST,
        returnTo: "/clients/room"
      });
    } catch (error) {
      res.status(error.status || 500).end(error.message);
    }
  },
  async callback(req, res) {
    try {
      await handleCallback(req, res, { afterCallback });
    } catch (error) {
      res.status(error.status || 500).end(error.message);
    }
  },
  async logout(req, res) {
    try {
      // Pass custom parameters to login
      await handleLogout(req, res, {
        returnTo: "/"
      });
    } catch (error) {
      console.error(error);
      res.status(error.status || 400).end(error.message);
    }
  }
});

Environment

Please provide the following:

  • "@auth0/nextjs-auth0": "^1.7.0"
  • "next": "^11.1.3"
  • "react": "^17.0.2"
  • "express": "^4.16.2"

Using Heroku to deploy this project

@adamjmcgrath
Copy link
Contributor

Hi @felixdasgupta - thanks for raising this

I can't see anything wrong with the code you've shared.

Take a look at auth0/express-openid-connect#145 (comment) and auth0/express-openid-connect#267 (comment) for an explanation of the error and some tips on debugging.

@adamjmcgrath adamjmcgrath added the question Further information is requested label Apr 6, 2022
@Widcket
Copy link
Contributor

Widcket commented Apr 20, 2022

Closing as it seems you're no longer experiencing this issue. Please feel free to ping if you'd prefer to reopen.

@Widcket Widcket closed this as completed Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants