当尝试在SharePoint网站中建立文件夹时,出现以下错误:
{
"error": {
"code": "accessDenied",
"message": "Access denied",
"innerError": {
"request-id": "61d3b5aa-857e-4ee2-9d0d-51d235ca7c5f",
"date": "2020-05-18T06:31:54"
}
}
}
注意:
msgraph-sdk-php
进行请求。这通常与权限有关,但是我的用户具有以下内容 天蓝色设置的权限:
Sites.Manage.All Delegated.
Sites.Read.All Delegated.
Sites.ReadWrite.All Delegated.
在my.env内部,我具有以下权限:
OAUTH_SCOPES='openid profile offline_access user.read calendars.readwrite mail.readwrite mail.send'
网址:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?%20state={someState}%20&scope=openid%20profile%20offline_access%20user.read%20calendars.readwrite%20mail.readwrite%20mail.send%20&response_type=code&approval_prompt=auto&redirect_uri=http://localhost:8080/office365/token/store%20&client_id={myclientId}
什么在这里导致错误?
答案 0 :(得分:1)
您可能已经请求了这些权限,但是在您收到管理员的“同意”之前,它们不会被激活。
AAD具有两种“同意”形式:管理员和用户。如果范围需要“管理员同意”,那么您需要 之前获得该同意,然后才能获得“用户同意”。您列出的所有 ngOnInit(): void {
this.filteredAccountOptions = this.accountControl.valueChanges.pipe(
startWith(''),
debounceTime(3000),
switchMap(value => this._accountFilter(value)),
);
}
private _accountSearch(searchedValue: string): Observable<any> {
return this.createDialogService.searchAccount(searchedValue).pipe(
map(success => JSON.parse(success.message)),
);
}
范围都需要管理员同意。
答案 1 :(得分:1)
您需要构建特殊的URL并将其提供给全局管理员以表示同意。 例如:https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-admin-consent
获得同意后,最多可能需要24小时才能获得您的许可。 另外,您可以在此处检查oauth令牌:https://jwt.io/
答案 2 :(得分:1)
您需要在OAUTH_SCOPES变量中添加一个或多个所需范围(Sites.Read.All,Sites.ReadWrite.All,Sites.Manage.All):
OAUTH_SCOPES='Sites.Manage.All ...'
因此您的授权URL的构建如下:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?scope=Sites.Manage.All ...&client_id=...
PS:上述范围均不需要admin consent。