You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Whoop自定义OAuth2提供商时NextAuth报OAUTH_CALLBACK_ERROR invalid_client错误

NextAuth 集成 Whoop OAuth2 时出现 invalid_client 错误

我在尝试用 NextAuth 对接自定义 OAuth2 服务商 Whoop 做认证时,完成 Whoop 端登录并重定向回应用后,NextAuth 抛出以下错误:

[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error invalid_client (Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)) {
  error: OPError: invalid_client (Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method))
      at processResponse (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/helpers/process_response.js:35:19)
      at Client.grant (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/client.js:1191:28)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Client.oauthCallback (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/client.js:520:30)
      at async oAuthCallback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/lib/oauth/callback.js:120:22)
      at async Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:18:83)
      at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38)
      at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)
      at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)
      at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:242:37) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'whoop',
  message: 'invalid_client (Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method))'
}

我的 NextAuth 配置代码如下:

// /api/auth/[...nextauth]/route.ts
import NextAuth, { AuthOptions } from "next-auth";

export const authOptions: AuthOptions = {
  //   debug: true,
  providers: [
    {
      id: "whoop",
      name: "Whoop",
      type: "oauth",
      token: "https://api.prod.whoop.com/oauth/oauth2/token",
      authorization: {
        url: "https://api.prod.whoop.com/oauth/oauth2/auth",
        params: {
          scope: "read:profile read:workout read:recovery",
        },
      },

      clientId: process.env.WHOOP_CLIENT_ID,
      clientSecret: process.env.WHOOP_CLIENT_SECRET,
      userinfo: "https://api.prod.whoop.com/developer/v1/user/profile/basic",
      profile(profile) {
        return {
          id: profile.user_id,
          first_name: profile.first_name,
          last_name: profile.last_name,
          email: profile.email,
        };
      },
    }
  ]
};

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };

我已经确认配置中的 Client ID、密钥、回调 URL 和权限范围都能正常配合 Whoop 使用,也手动设置过 profile 返回值测试,但错误依然存在,求调试指导。


内容的提问来源于stack exchange,提问作者Eliot Hertenstein

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 07:15:02