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

1aaf6o9v  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(96)

我有一个应用程序,在其中我使用next-auth实现linkedin auth,特别是next js 13和app router。它会进入同意屏幕,但在终端中从那里回调后,它会抛出以下错误,用户未正确验证。我已经检查了作用域和其他参数,它们都正确传递。在这方面的任何帮助真的很感激。

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

我尝试了几乎所有的自定义authoptions。

sqougxex

sqougxex1#

自2023年8月1日起,LinkedIn将使用switched new Sign In with LinkedIn implementations
这意味着默认的next-auth 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,
        };
      },
   })

我相信这是很快将被合并,所以很快只是升级到最新应该解决这个问题。

相关问题