gpt4 book ai didi

javascript - azure-graph 产生 Request_BadRequest : Invalid domain name in the request url

转载 作者:行者123 更新时间:2023-12-01 01:23:18 25 4
gpt4 key购买 nike

我正在尝试使用 Node.js 通过 ID 检索用户对象。这是我的代码:

const MsRest = require('ms-rest-azure');    
const credentials = await MsRest.loginWithServicePrincipalSecret(keys.appId, keys.pass, keys.tenantId, { tokenAudience: 'graph' });
const GraphkManagementClient = require('azure-graph');
const client = new GraphkManagementClient(credentials, subscriptionId);
return client.users.get(principalID);

但是 client.users.get(principalID) 生成一个返回的请求:

Request_BadRequest: Invalid domain name in the request url

这是它生成的 url(使用真实值而不是 {tenant id} 和 {user id}):

https://graph.windows.net/{tenant id}/users/{user id}?api-version=1.6

最佳答案

对于azure-graph sdk,似乎应该是GraphkManagementClient(credentials,'<tenantId>') .

可以引用这个sample :

const AzureGraphClient = require('azure-graph');
const MsRestAzure = require('ms-rest-azure');

const options = {
tokenAudience: 'graph',
domain: '<tenantId>'
};

MsRestAzure.loginWithServicePrincipalSecret(
'clientId or appId',
'secret or password',
'domain or tenantId',
options,
(err, credentials) => {
if (err) throw err;

let graphClient = AzureGraphClient(credentials, '<tenantId>');

// ..use the client instance to manage service resources.
});

还提到了here :

var graphRbacManagementClient = require('azure-graph');
var client = new graphRbacManagementClient(credentials, tenantId);

关于javascript - azure-graph 产生 Request_BadRequest : Invalid domain name in the request url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54061660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com