天蓝色图会抛出“访问令牌丢失或格式错误". [英] azure-graph throws "Access Token missing or malformed"

查看:71
本文介绍了天蓝色图会抛出“访问令牌丢失或格式错误".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Note.js项目中完美使用了Azure API.

I flawlessly use azure APIs in my Note.js project.

登录:

const MsRest = require('ms-rest-azure');
MsRest.loginWithServicePrincipalSecret(keys.appId, keys.pass, keys.tenantId);

创建资源组:

const { ResourceManagementClient } = require('azure-arm-resource');
const resourceClient = new ResourceManagementClient(credentials, subscriptionId);
resourceClient.resourceGroups.createOrUpdate(groupName, groupParameters);

它可以完美地工作,azure-arm-authorization,azure-arm-compute和azure-arm-network模块也是如此.

It works flawlessly, and so do azure-arm-authorization, azure-arm-compute and azure-arm-network modules.

但是,我无法使用azure-graph API:

However, I do not manage to use azure-graph API:

const GraphkManagementClient = require('azure-graph');
const client = new GraphkManagementClient(credentials, subscriptionId);
return client.users.get(principalID);

最后一行抛出错误:

访问令牌丢失或格式错误

Access Token missing or malformed

推荐答案

Active Directory Graph服务基于租户,与其他Azure服务(例如资源管理器,计算等)相比,其令牌访问者不同,在其他所有这些Azure服务中,这些服务都具有基于订阅的令牌访问者.因此,获取的令牌将适用于其他Azure服务,但不适用于Graph,因此您收到了相应的令牌错误.请参考 https ://github.com/Azure/azure-sdk-for-node/tree/master/lib/services/graphManagement#how-to使用以了解使用node.js实现Graph的方法

Active Directory Graph service is tenant based and has a different token audience compared to other Azure services like resource manger, compute etc. where all these has subscription based token audience. so, the token that is acquired will work for other Azure Services but not for Graph and thus you received the respective token error. Please refer to https://github.com/Azure/azure-sdk-for-node/tree/master/lib/services/graphManagement#how-to-use to understand the implementation of Graph with node.js

这篇关于天蓝色图会抛出“访问令牌丢失或格式错误".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆