访问令牌来自错误的颁发者 'https://sts.windows.net'

The access token is from the wrong issuer 'https://sts.windows.net'

我正在使用 'azure-arm-resource' 为我的节点 js 项目获取所有 azure 资源。

https://www.npmjs.com/package/azure-arm-resource

但是使用这个我得到了一些错误,

 msRestAzure.interactiveLogin().then(credentials => {
  const azureResources = new resourceManagement.ResourceManagementClient(credentials, subscriptionId);

  azureResources.resources
    .list()
    .then(res => {
      if (filter) {
        return res.filter(r => r.kind === filter);
      } else {
        return res;
      }
    })
    .then(d => {
      console.log('Done Resources');
    });
});
console.log('Pulling...');
 }

错误,

 Uncaught (in promise) Error: The access token is from the wrong issuer 
'https://sts.windows.net/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/'.
 It must match the tenant 'https://sts.windows.net/xxxx-xxx-xxxx-xxxx- 
 c3xxx4xxffd57xx7/' 
 associated with this subscription. Please use the authority (URL) 
 'https://login.windows.net/xxxx-xxxx-xxx-xxxx-xxxxxxxx' to get the token. 
  Note, if the subscription is transferred to another tenant there is no 
 impact to the services, but information about new tenant could take time to 
  propagate (up to an hour). If you just transferred your subscription and  
  this error message, please try back later.

Azure 交互式登录中未定义设备令牌凭据

这意味着订阅不属于您登录帐户所在的租户。

确保您登录的帐户可以访问所使用的订阅。

当您登录门户时,使用组织 ID something@yourcompany-name.com 时,它会起作用,但是当使用实时 ID something@gmail.com 时,我们需要传递 TenantId .

主要目的是让用户的登录体验变得简单。因此,我们从最少的必需参数开始。对于 interactiveLogin(),我认为它是零。但这是不正确的。使用liveID时必须提供TenantId或domain。