question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Azure AD] Callback Error , expected 200 OK, got: 404 Not Found

See original GitHub issue

Description 🐜

When trying to authenticate with AzureADProvider and next-auth 4.0.0-beta, I get OAUTH_CALLBACK_ERROR

Is this a bug in your own project?

No

How to reproduce ☕️

Provider

import NextAuth from "next-auth"
import AzureADProvider from 'next-auth/providers/azure-ad';



export default NextAuth({
    providers: [
        AzureADProvider({
            clientId: process.env.AZURE_AD_CLIENT_ID,
            clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
            tenantId: process.env.AZURE_AD_TENANT_ID,
          }),
    ],
    pages: {
        signIn: '/auth/signin',
    }

  }) 

Signin

 {Object.values(providers).map((provider) => (
                          <button key={provider.name} onClick={() => signIn(provider.id)} className="inline-flex justify-center px-10 py-3 text-black align-middle bg-white border rounded shadow">
                          <img
                            src="/images/microsoft.svg"
                            style={{ width: "24px", height: "24px" }}
                            alt=""
                          />
                          <span className="sr-only">Continue with</span>
                          <span className="px-4">Login with Office 365</span>
                        </button>
            ))}

Screenshots / Logs 📽

https://next-auth.js.org/errors#oauth_callback_error expected 200 OK, got: 404 Not Found {
  error: {
    message: 'expected 200 OK, got: 404 Not Found',
    stack: 'OPError: expected 200 OK, got: 404 Not Found\n' +
      '    at processResponse (/home/sriram/projects/hr-padink/node_modules/openid-client/lib/helpers/process_response.js:48:11)\n' +
      '    at Client.grant (/home/sriram/projects/hr-padink/node_modules/openid-client/lib/client.js:1265:26)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
      '    at async Client.oauthCallback (/home/sriram/projects/hr-padink/node_modules/openid-client/lib/client.js:561:24)\n' +
      '    at async oAuthCallback (/home/sriram/projects/hr-padink/node_modules/next-auth/core/lib/oauth/callback.js:105:16)\n' +
      '    at async Object.callback (/home/sriram/projects/hr-padink/node_modules/next-auth/core/routes/callback.js:50:11)\n' +
      '    at async NextAuthHandler (/home/sriram/projects/hr-padink/node_modules/next-auth/core/index.js:103:28)\n' +
      '    at async NextAuthNextHandler (/home/sriram/projects/hr-padink/node_modules/next-auth/next/index.js:40:7)\n' +
      '    at async /home/sriram/projects/hr-padink/node_modules/next-auth/next/index.js:80:32\n' +
      '    at async Object.apiResolver (/home/sriram/projects/hr-padink/node_modules/next/dist/server/api-utils.js:102:9)',
    name: 'OPError'
  },
  providerId: 'azure-ad',
  message: 'expected 200 OK, got: 404 Not Found'
}

Environment 🖥

System: OS: Linux 5.11 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor Memory: 3.06 GB / 31.31 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node Yarn: 1.22.11 - ~/.nvm/versions/node/v14.16.0/bin/yarn npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm Browsers: Chrome: 93.0.4577.82 Firefox: 93.0 npmPackages: next: latest => 12.0.1 next-auth: ^4.0.0-beta.5 => 4.0.0-beta.5 react: ^17.0.2 => 17.0.2

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Krithiikcommented, Jan 19, 2022

May I know , If this is resolved ? Because I face the same problem with Spotify provider. Though the authorization is completed, this issue arises. It works well for logging in through email/username and password but fails on using other means eg: Google account or phone number.

node: 14.17.3 next-auth: ^4.1.2

1reaction
viperxeyescommented, Jan 22, 2022

May I know , If this is resolved ? Because I face the same problem with Spotify provider. Though the authorization is completed, this issue arises. It works well for logging in through email/username and password but fails on using other means eg: Google account or phone number. node: 14.17.3 next-auth: ^4.1.2

I’m joining. I have the same only when logging in using facebook. It’s ok with google. When logging in with facebook I have: OPError: expected 200 OK, got: 400 Bad Request, name: ‘OAuthCallbackError’

code:

FacebookProvider({
      clientId: !!process.env.PROVIDER_FACEBOOK_CLIENT
        ? process.env.PROVIDER_FACEBOOK_CLIENT
        : "",
      clientSecret: !!process.env.PROVIDER_FACEBOOK_SECRET
        ? process.env.PROVIDER_FACEBOOK_SECRET
        : "",
)}

node: v16.13 next: v12.0.8 next-auth: v4.1.2

Same thing here , was working fine few about a week ago , now 3 days ago i started getting this error with facebook too , expected 200 OK, got: 400 Bad Request, name: ‘OAuthCallbackError’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure AD B2C with Next-auth OPError: expected 200 OK, got
But now I'm stucked with error. Any idea what's wrong? Error https://next-auth.js.org/errors#signin_oauth_error expected 200 OK, got: 404 Not ...
Read more >
Azure AD 404 error when login with Microsoft account
I created a Cognito userpool and an Azure AD b2c application. I connected Azure AD b2c to Cognito as a OpenID Connect identity...
Read more >
Azure B2C: Unable to retrieve document from v2.0 .well ...
I am trying to use Azure B2C in my dotnet core web app in order to use a ... Configuration to sign-in users...
Read more >
Azure AD authentication & authorization error codes
Authentication failed due to flow token expired. Expected - auth codes, refresh tokens, and sessions expire over time or are revoked by the...
Read more >
Use managed identity with an application - Azure Service Fabric
The 'status code' field of the HTTP response header indicates the success status of the request; a '200 OK' status indicates success, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found