NextJS + NextAuth + IdentityServer4。不调用 /connect/token 端点

问题描述 投票:0回答:1

我真的不明白我做错了什么。也许我不明白它是如何运作的..

使用 NextAuth,我尝试使用 Net Core 中的 IdentityServer 来授权应用程序。 我成功显示了来自身份服务器的登录页面,并且可以登录(并且它重定向到我的应用程序,查询字符串中带有

code
,但之后,无论我做什么,NextAuth 都不会调用
/connect/token
。这里是我的代码。

export const authOptions = {
  providers: [
    {
      id: "custom-provider",
      name: "custom-provider",
      type: "oauth",
      clientId: "nc-setcompany",
      checks: ["pkce", "state"],
      wellKnown: "https://localhost:44392/.well-known/openid-configuration",
      authorization: {
        params: {
          scope: "setcompany.api openid profile",
          redirect_uri: "http://localhost:3000/callback",
          site: "5485E2C6-A3B4-4129-956F-F1059133CF03",
          response_mode: "query",
          response_type: "code",
        },
      },
    },
  ],
};

如果我使用回调,则不会触发任何人,如果我在文档中指定 de

token
端点,它也不会调用它(但是他们不推荐它,而是像我一样使用众所周知的)。

我尝试了很多配置,将会话策略设置为“jwt”,修改response_mode和response_type,专门将参数设置为令牌端点(grant_type:authorization_code)等等。没有任何效果。

它甚至没有失败,根本没有请求(chrome 控制台显示没有对令牌端点的请求)。

我缺少什么?

IdentityServer 有这个端点,因为它已被其他“

create-react-apps
”成功使用(这是我们公司的第一个 NextJS 应用程序)。

这是根本没有发生的部分:

我是否必须从回调/page.tsx 手动进行此调用还是什么? (是的,我尝试了 NextAuth 的 IdentityServerProvider,结果完全相同。)

next.js oauth identityserver4 openid next-auth
1个回答
0
投票

我认为你应该在重定向 URL http://localhost:3000/callback 中使用 HTTPS,因为由于相同的站点设置,当你收到客户端的回调时,浏览器会阻止 cookie。

© www.soinside.com 2019 - 2024. All rights reserved.