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.