English 中文(简体)
6. 与谷歌提供商在下期返回时的尝试
原标题:Login attempt with GoogleProvider in next-auth returns OAUTH_CALLBACK_ERROR and message: checks.state argument is missing

I m是关于我的联合材料全面课程的项目,I m与下乌斯特谷歌提供者讨论一些问题(第4.18.8章)。

今天早上,所有工作都很出色。 在与Google提供商取得成功标识后,使用“使用Session()”使谷歌的证书在奥索尔。 标志,我全心全意,走到吉姆。 在我回头之后(当然抽出一个显示器),我将获得这些 go光证书,在首页上显示用户名称,但令我感到惊讶的是,我开始看到这一警示错误。

FYI, env. local is interprety set up with GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET. 我甚至删除了我关于谷歌的全权证书,并创建了另一个测试证书,但没有幸运。

在试图登录时,我发现这一错误:

[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error checks.state argument is missing {
  error: TypeError: checks.state argument is missing
      at Client.callback (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modulesopenid-clientlibclient.js:387:13)
      at oAuthCallback (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
ext-authcoreliboauthcallback.js:127:29)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)    
      at async Object.callback (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
ext-authcore
outescallback.js:52:11)
      at async AuthHandler (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
ext-authcoreindex.js:201:28)
      at async NextAuthHandler (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
ext-auth
extindex.js:23:19)
      at async C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
ext-auth
extindex.js:59:32
      at async Object.apiResolver (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserverapi-utils
ode.js:363:9)
      at async DevServer.runApi (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserver
ext-server.js:487:9)
      at async Object.fn (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserver
ext-server.js:749:37)
      at async Router.execute (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserver
outer.js:253:36)
      at async DevServer.run (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserverase-server.js:384:29)
      at async DevServer.run (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserverdev
ext-dev-server.js:741:20)
      at async DevServer.handleRequest (C:JoãoDropboxPessoalProjetos Webdesign	rading-center
ode_modules
extdistserverase-server.js:322:20) {
    name:  OAuthCallbackError ,
    code: undefined
  },
  providerId:  google ,
  message:  checks.state argument is missing 

在我的谷歌账户点击后,我注意到一些东西,涉及我的DevTools网络:

First, it will make a request that returns status code 302 on "consent?authuser=0&part=......." After that, another request to "google?state=......" returns 302 also. Then I get an error on request to http://127.0.0.1:3000/api/auth/error?error=OAuthCallback also with 302 status code. Finally, I get an error on request to http://127.0.0.1:3000/api/auth/signin?error=OAuthCallback that returns 404

我不理解这一点,但我很相信,我无意对这些要求产生302个错误。

我的法典就是这样。

www.un.org/Depts/DGACM/index_spanish.htm 我有一个叫作这一职能的纽子:。

const handleGoogleLogin = async () => {
    await signIn( google , {
        redirect: true,
        callbackUrl:  http://127.0.0.1:3000/user/dashboard 
    })
}

www.un.org/Depts/DGACM/index_spanish.htm My [...nextauth].js file:

export const authOptions = {
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET
    })

  ],

  session: {
    strategy: "jwt",
  }, 

  jwt: {
    secret: process.env.JWT_TOKEN
  },

  adapter: MongooseAdapter(process.env.MONGODB_URI),

}
export default NextAuth(authOptions)

见我

如果你认为有必要,我可以自由地向我提问。

Greatly appreciated.
João Textor

最佳回答

固定。

callbackUrl should not be like this http://127.0.0.1:3000/user/dashboard, but like this: /user/dashboard

简单固定,简单错误,ALOT OF HEADACHE!

问题回答

包括:

 GoogleProvider({
  clientId: process.env.GOOGLE_CLIENT_ID,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET,


  callbackUrl:  /home/ruteOnlyCanAccessUsersLogged/remplaceMe ,


  authorization: {

// params recomend in documentation to refresh token, Exclusive to google provider
// https://next-auth.js.org/providers/google

    params: {
      prompt:  consent ,
      access_type:  offline ,
      response_type:  code 
    }
  }
})
// other options and methods
 
    
}
export default NextAuth(authOptions)

您可以尝试增加试捕量。 其他一些法典正在坠毁。

后续讨论:https://github.com/nextauthjs/next-auth/discuss/7491

根据每部电车,通过使用以下代码进行国家检查:

GoogleProvider({
  clientId: process.env.GOOGLE_ID,
  clientSecret: process.env.GOOGLE_SECRET,
  checks: [ none ]
}),




相关问题
Connecting Actionscript 3.0 with a C++ backend?

I am curious to know if there is a way of connecting a flash front-end to a C++ driven backend? I m not currently working on a project that involves this, but I found out about an application used in ...

Django - update a model won t delete the old FileField

I am implementing an application with django, which has a model with a FileField: class Slideshow(models.Model): name = models.CharField(max_length=30,unique=True) thumbnail = models....

MS Access 2003 - Really simple query

If I try to duplicate an access file (this file is split into mdb and be mdb, and also has mde files), by importing everything into a brand new access application, why won t the table links work? ...

Building a website backend in c#, compiled to a binary

I am creating a novel website that integrates web feeds from around the internet. I want to build a backend that does CPU intensive analysis of the web data on a regular basis, which will eventually ...

Need a cool hotkey for my hidden website-login

I am developing a CMS. One of the greatest everyday annoyances when working with it is that when you are on a front-end page, not logged in, and want to make a change, you need to go to the back-end ...

热门标签