![](/img/trans.png)
[英]Accessing calendar via Microsoft Graph API while the user is not signed in
[英]Creating a user via Microsoft Graph API
我正在尝试执行此 curl 请求
curl --location --request POST 'https://graph.microsoft.com/v1.0/users' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {BEARER_TOKEN}' \
--data-raw '{
"accountEnabled": true,
"displayName": "displayName-value",
"mailNickname": "mailNickname-value",
"userPrincipalName": "test666@mytennant.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "password"
}
}'
我不断得到
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"date": "2020-10-23T14:01:06",
"request-id": "caf9e0be-88fc-4a4e-a6eb-fed1ccedb90c",
"client-request-id": "caf9e0be-88fc-4a4e-a6eb-fed1ccedb90c"
}
}
}
有人可以帮我弄清楚这里出了什么问题吗?
根据您提供的错误,您似乎没有创建用户的正确权限。
在令牌中,您缺少权限,因此在发出图形请求之前,您需要将令牌与
User.ReadWrite.All, Directory.ReadWrite.All.
我提出了以下请求,但没有获得所需的许可,然后我收到了与您在下面看到的相同的错误
后来我添加了权限并请求了新令牌,然后进行了图形调用。 现在我成功地创建了用户
卷曲
curl --location --request POST 'https://graph.microsoft.com/v1.0/users' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{ "accountEnabled": true, "displayName": "displayName-value", "mailNickname": "mailNickname-value", "userPrincipalName": "upn-value1@xx.live", "passwordProfile" : { "forceChangePasswordNextSignIn": true, "password": "xx@123" } }'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.