需要帮助:AADSTS700016:在目录 Azure 帐户 AD 中找不到带有标识符的应用程序?

Need help: AADSTS700016: Application with identifier was not found in the directory Azure Account AD?

当我在 Azure 的 VM 上 运行 我的 node.js 应用程序时,我对 Azure AD Oauth2 令牌的请求工作正常。它正在使用另一个团队的客户端 id/secret 发出请求,因为在代码的更下方,该程序将使用该令牌对他们的服务进行 REST API 调用。如果我的程序(node.js 应用程序)是从 Github 工作流程启动的,则程序在 fetching/requesting 令牌后会出错。 (在出现此错误之前,工作流成功运行了 3 次。现在每次都会出现此错误。)感谢您的帮助!非常感谢,我在这方面没有太多经验。

async function getToken(config) {
  const params = new URLSearchParams()
  params.append('grant_type', 'client_credentials')
  params.append('client_id', config.clientId)
  params.append('client_secret', config.clientSecret)
  params.append('scope', config.scopeUrl)

  //url = https://login.microsoftonline.com/{{AD.tenantId}}/oauth2/v2.0/token

  const response = await fetch(config.tokenRequestUrl, { method: 'POST', body: params })
  const jsonObj = await response.json()

  console.log('!!!!JSON='+JSON.stringify(jsonObj))

  if ((typeof jsonObj.access_token !== 'undefined') && (jsonObj.access_token != null)) {
    return jsonObj.access_token
  } else {
    return null
  }
}

输出:

!!!!3S0N=***"error":"unauthorizedclient","errordescription":"AADSTS700016: Application with identifier '***' was not found in the directory 'xxxxx Azure Account AD'. This can happen if the application has
not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.***

我想通了! Github 工作流使用了错误的客户端 id/secret。