简体   繁体   中英

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

My request for an Azure AD Oauth2 token works fine when I run my node.js app on a VM on Azure. It's making the request using another team's client id/secret because further down in the code, the program will make REST APIs calls to their services using that token. The program gets an error after fetching/requesting a token if my program (node.js app) is launched from a Github workflow. (The workflow worked successfully three times before getting this error. The error occurs every time now.) Thank you for your help! It's much appreciated and I don't have much experience in this area.

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
  }
}

Output:

!!!!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.***

I figured it out! The Github workflow was using the wrong client id/secret.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM