azure-graph throws “Access Token missing or malformed”

天涯浪子 提交于 2019-12-11 19:47:27

问题


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

Login:

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

Create resource group:

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

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

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);

The last line throws an error:

Access Token missing or malformed


回答1:


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



来源:https://stackoverflow.com/questions/54049755/azure-graph-throws-access-token-missing-or-malformed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!