如何使用节点 OIDC 提供程序中的令牌端点获取 access_token

问题描述

我尝试使用节点 oidc 提供程序使用授权代码获取 access_token 和 refresh_token。我得到了 auth_code。但我无法获得访问令牌和刷新令牌 如何解决此问题。我参考了很多文档,但我找不到。

OIDC 配置

  const oidc = new Provider('http://localhost:3000',{
  clients: [
    {
      client_id: 'foo',client_secret: 'bar',redirect_uris: ['https://jwt.io'],// using jwt.io as redirect_uri to show the ID Token contents
      response_types: ['code'],grant_types: ['authorization_code'],token_endpoint_auth_method: 'none',},],cookies: {
    keys: 'secretkey'
  },pkce: {
    required: true
  },});

// Heroku has a proxy in front that terminates ssl,you should trust the proxy.
oidc.proxy = true;
app.use(oidc.callback())

我也有 auth_code

enter image description here

enter image description here

如何使用 node-oidc provider 获取访问令牌和刷新令牌

解决方法

  1. 您的访问令牌请求缺少 PKCE code_verifier 参数。
  2. 您客户的身份验证方法设置为 none,因此您不应传递任何授权标头。

您可以使用 DEBUG=oidc-provider:* 开始您的提供程序进程以获取有关这些错误的更多详细信息。