【问题标题】:status 401 Unauthorized Auth0 access token Node JS Heroku状态 401 未经授权的 Auth0 访问令牌 Node JS Heroku
【发布时间】:2021-02-23 18:32:03
【问题描述】:

所以我正在尝试获取访问令牌以删除用户。

var options = {
  method: 'POST',
  url: 'https://dev-owihjaep.auth0.com/oauth/token',
  headers: {'content-type': 'application/json'},
  data: {
    grant_type: 'client_credentials',
    client_id: 'RGPTciPqTAlJSDoO3zkL4GT1HV3fsptj',
    client_secret: process.env.AUTH0_CLIENT_SECRET,
    audience: 'https://dev-owihjaep.auth0.com/api/v2/'
   }
  };
  let accessTokenResponse = await axios.request(options)

它在 localhost 中工作,但由于某种原因,我部署的应用程序得到了 status: 401, statusText: 'Unauthorized' 和 data: { error: 'access_denied', error_description: 'Unauthorized' }。我为我的客户创建了客户端授权,确保在 Auth0 管理 API 设置中的机器到机器应用程序中为我的应用程序切换了授权,并确保为我的应用程序检查了客户端凭据的授权类型。我该如何解决这个错误?

【问题讨论】:

    标签: node.js heroku auth0


    【解决方案1】:

    我必须将我的 .env 环境变量(process.env.AUTH0_CLIENT_SECRET)添加到我的 Heroku Config Vars。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-06
      • 2017-07-05
      • 2020-08-12
      • 2017-06-11
      • 1970-01-01
      • 2019-11-02
      • 2016-05-17
      • 2014-01-30
      相关资源
      最近更新 更多