Next.js Discord

Discord Forum

Error: Instagram OAuth with NextAuth

Unanswered
Mudi posted this in #help-forum
Open in Discord
Avatar
MudiOP
Hi, everybody.
This is Kenneth from Canada.
I have trouble integrating instagram oauth into my next.js app with next-auth.
Here is the error messsage log:
[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error expected 200 OK, got: 400 Bad Request {
  error: OPError: expected 200 OK, got: 400 Bad Request
      at processResponse (C:\_Data\workspace\frontend-server\node_modules\openid-client\lib\helpers\process_response.js:41:11)
      at Client.userinfo (C:\_Data\workspace\frontend-server\node_modules\openid-client\lib\client.js:1264:18)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async oAuthCallback (C:\_Data\workspace\frontend-server\node_modules\next-auth\core\lib\oauth\callback.js:131:17)
      at async Object.callback (C:\_Data\workspace\frontend-server\node_modules\next-auth\core\routes\callback.js:52:11)
      at async AuthHandler (C:\_Data\workspace\frontend-server\node_modules\next-auth\core\index.js:208:28)
      at async NextAuthApiHandler (C:\_Data\workspace\frontend-server\node_modules\next-auth\next\index.js:22:19)
      at async NextAuth._args$ (C:\_Data\workspace\frontend-server\node_modules\next-auth\next\index.js:108:14) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'instagram',
  message: 'expected 200 OK, got: 400 Bad Request'
}

and my code comes here:
if (!(status === "loading") && !session) void signIn(website);
    if (session && (session as any)[website] && status === "authenticated") {
      window.opener.postMessage({ event: "close", data: `Closing ${website} auth window` }, process.env.NEXT_PUBLIC_FRONTEND_URL as string);
      setTimeout(() => {
        window.close();
      }, 100);
    }

I want to know why this error happens, and how to fix this error.
Facebook oauth is working, but only instagram is not working, showing above error.
Urgently need your help!😩
Thank you very much for your attention.
Image

0 Replies