3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Auth.jsのv5でLINEプロバイダーを使用してsignInするとエラーになる'state' is not specified.

Last updated at Posted at 2024-09-11

問題

AUth.jsのv5を使って以下のコードでsignInを呼び出しても、エラーとなる。
日本語で書かれている記事も無かったため、誰かのためになればと思い記載。

エラー内容

error=INVALID_REQUEST
error_description='state' is not specified.

問題のコード

export const { handlers, signIn, signOut, auth } = NextAuth({
  providers: [LINE({
    clientId: process.env.AUTH_LINE_ID,
    clientSecret: process.env.AUTH_LINE_SECRET,
  })],
}

解決策

providersのLINEのパラメータにchecks:["state"]を追加する。
具体的には以下の通り。

解決したコード

export const { handlers, signIn, signOut, auth } = NextAuth({
  providers: [LINE({
    clientId: process.env.AUTH_LINE_ID,
    clientSecret: process.env.AUTH_LINE_SECRET,clientSecret: process.env.AUTH_LINE_SECRET、
    checks:["state"],
  })],
}

参考サイト

3
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?