【问题标题】:OAuth 2.0 Azure Active Directory <> next-authOAuth 2.0 Azure Active Directory <> next-auth
【发布时间】:2021-04-16 19:00:09
【问题描述】:

我正在尝试使用 next-auth 库通过 OAuth 2.0 调用 Azure Active Directory,但不确定如何执行此操作。

我的 /api/[...nextauth].js 中的提供程序格式目前是:

providers: [
{
    id: 'azure',
    name: 'Azure Active Directory',
    type: 'oauth',
    version: '2.0',
    scope: 'read',
    accessTokenUrl: 'https://login.microsoftonline.com/{directory_id}/oauth2/v2.0/token',
    authorizationUrl: 'https://login.microsoftonline.com/{directory_id}/oauth2/v2.0/authorize',
    clientId: process.env.OAUTH_APP_ID,
    clientSecret: process.env.OAUTH_APP_PASSWORD,
  },

这似乎不起作用(错误:“请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配:”)。我该怎么办?

【问题讨论】:

    标签: azure oauth-2.0 azure-active-directory


    【解决方案1】:

    我的回答已经很晚了,但是为了回答这个问题:

    通常,此消息意味着您缺少正确的重定向 URI。 在 Azure 中,打开您的应用注册,转到身份验证并在“单页应用程序”下输入重定向 URI。

    在这种情况下,它将类似于 http://localhost/api/auth/callback/azure 用于您的本地开发。

    【讨论】:

      猜你喜欢
      • 2017-06-19
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 2014-12-27
      • 1970-01-01
      • 2014-01-06
      • 2018-04-21
      • 2021-09-14
      相关资源
      最近更新 更多