【发布时间】:2020-11-30 17:32:09
【问题描述】:
问题
我正在尝试构建一个与Microsoft Graph API 集成的应用程序。
我在 Azure 中有一个管理员帐户,并通过门户设置了一个新应用程序。 我已经下载并安装了PHP SDK,并设法设置了所有内容,以便成功获取用户。
我可以登录应用程序并授予使用我的信息的权限(我请求的权限是Directory.ReadWrite.All,但即使只是请求User.ReadWrite.All 对我不起作用),但是,我的问题似乎是我无法访问其他用户。
以下仅返回我自己的用户:
$graph = new Graph();
$graph->setAccessToken('/* SOMETOKEN */');
$users = $graph->createRequest('GET', '/users')
->setReturnType(User::class)
->execute();
发布新用户返回 404 错误:
$newUser = new User();
$newUser->setAccountEnabled(true);
$newUser->setGivenName('first_name');
$newUser->setSurname('last_name');
$newUser->setUserPrincipalName('some.email@address.com');
$password = new PasswordProfile();
$password->setPassword('some_password');
$newUser->setPasswordProfile($password);
$user = $graph->createRequest('POST', '/users')
->attachBody($newUser)
->execute();
返回:
{
"error": {
"code": "",
"message": "No HTTP resource was found that matches the request URI 'https://outlook.office365.com:444/profile/v1.0/users('CID:a8ef4446a149de4d')/profile?api-version=AGSV1-internal'.",
"innerError": {
"date": "/* timestamp */",
"request-id": "/* an id */",
"client-request-id": "/* an id */"
}
}
}
即使尝试使用 Microsoft 的 Graph Explorer 也会遇到同样的错误。
我是否认为这可能是帐户设置问题?
更新
这是 Graph Explorer 返回的错误消息
{
"error": {
"code": "",
"message": "No HTTP resource was found that matches the request URI 'https://outlook.office365.com:444/profile/v1.0/users('CID:a8ef4446a149de4d')/profile?api-version=AGSV1-internal'.",
"innerError": {
"date": "2020-11-30T16:51:41",
"request-id": "743030b4-8835-4a9f-9e3e-d35919a1c289",
"client-request-id": "c40cd440-d873-ba38-dce7-8669bc561e64"
}
}
}
【问题讨论】:
-
能否提供相关ID和时间戳
-
@SruthiJ-MSFTIdentity by "correlation ID",你的意思是请求 ID 吗?如果没有,我不确定在哪里可以找到它
-
是的,请在错误信息中提供请求id和时间戳
-
@SruthiJ-MSFTIdentity 我已更新问题以包含此
-
您能否检查一下 jwt.ms 中的令牌,您需要拥有 User.ReadWrite.All 权限
标签: php microsoft-graph-api microsoft-graph-sdks