Getting invalid_client error using next-auth FOR COGNITO

clock icon

asked 3 months ago Asked

message

3 Answers

eye

210 Views

I AM EDITED.

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: 'cognito',
  message: 'invalid_client'
}

Why am I getting this error?

3 Answers

next-auth will run it in the server side, which is why you would need a Confidential client instead of a Public client.

This is how AWS Cognito described different type of clients -

Public client: A native, browser or mobile-device app. Cognito API requests are made from user systems that are not trusted with a client secret.

Confidential client A server-side application that can securely store a client secret. Cognito API requests are made from a central server.

Hmm, this is a really interesting question. It appears you don't really have an idea of what you're talking about.

Write your answer here

Top Questions