next-auth linkedin 身份验证给出错误:OPError:预期 200 OK,得到:403 Forbidden

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

我有一个应用程序,其中我使用 next-auth 特别是带有应用程序路由器的 next js 13 来实现 linkedin auth。它进入同意屏幕,但在终端中回调后,它会抛出以下错误,并且用户未经过正确身份验证。我已经检查了范围和其他参数,它们已正确传递。非常感谢在这方面的任何帮助。

https://next-auth.js.org/errors#oauth_callback_error expected 200 OK, got: 403 Forbidden {
  error: OPError: expected 200 OK, got: 403 Forbidden

我尝试了几乎所有来自自定义授权选项的方法。

next.js linkedin-api next-auth
1个回答
0
投票

自 2023 年 8 月 1 日起,LinkedIn 将新的“使用 LinkedIn 登录”实现切换为使用 OpenID Connect (OIDC)

这意味着默认的下一个身份验证 LinkedIn 提供商选项不再有效。

一组工作选项的示例位于此评论

LinkedInProvider({
      clientId: process.env.LINKEDIN_CLIENT_ID,
      clientSecret: process.env.LINKEDIN_CLIENT_SECRET,
      authorization: {
        params: { scope: 'openid profile email' },
      },
      issuer: 'https://www.linkedin.com',
      jwks_endpoint: 'https://www.linkedin.com/oauth/openid/jwks',
      profile(profile, tokens) {
        const defaultImage =
          'https://cdn-icons-png.flaticon.com/512/174/174857.png';
        return {
          id: profile.sub,
          name: profile.name,
          email: profile.email,
          image: profile.picture ?? defaultImage,
        };
      },
   })

我相信这很快就会被合并,所以很快只需升级到最新版本就可以解决这个问题。

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