Getting invalid_client error using next-auth for cognito

  Kiến thức lập trình

I have a Next JS app, a next-auth library and aws cognito to store user information. I created a public client in my Cognito userpool and using that userpool id & client id, I initially successfully connected my application to Cognito. Back then, I was not using next-auth.

Now I decided to use next-auth and take all this server side. I’m still using the old cognito client. It properly redirects me to Cognito login UI, but after a successful login, the following error is triggered by next-auth

https://next-auth.js.org/errors#oauth_callback_error invalid_client {
  error: OPError: invalid_client ...

Then there is a trace of the error followed by

  name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'google',
  message: 'invalid_client'
}

Why am I getting this error?

Given Next JS link states that ‘OAUTH_CALLBACK_ERROR’ signifies

This can occur during the handling of the callback if the code_verifier cookie was not found or an invalid state was returned from the OAuth provider.

I’m not sure what this ‘code_verifier’ cookie is, since I didn’t try to do anything advanced with next-auth, I haven’t altered any configuration that would trigger this.

New contributor

Shamimatul Jannat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT