【发布时间】:2021-05-05 12:45:28
【问题描述】:
我有一个项目需要通过客户端凭据将文件上传到选定的共享点站点。 我在我的 APP 上应用了 Site.Selected Application Permission,并使用 Admin Azure AD 授予它“写入”角色。
{
"roles": ["write"],
"grantedToIdentities": [{
"application": {
"id": "clientid",
"displayName": "blobtest"
}
}]
}
以下是从提供者获取访问令牌的方法
public IGraphServiceClient getAuthProvider() {
IAuthenticationProvider mAuthenticationProvider;
try {
String accessToken = getAuthToken();
mAuthenticationProvider = request -> request.addHeader("Authorization",
"Bearer " + accessToken);
} catch (Exception e) {
throw new Error("Could not create a graph client: " + e.getLocalizedMessage());
}
IGraphServiceClient graphClient =
GraphServiceClient
.builder()
.authenticationProvider(mAuthenticationProvider)
.buildClient();
return graphClient;
}
但是,在出现以下结果时,上传遇到了一些问题。
2021-05-05 20:28:24.137 INFO 2148 --- [nio-8082-exec-1] os.web.servlet.DispatcherServlet:初始化 Servlet 'dispatcherServlet'
2021-05-05 20:28:24.147 INFO 2148 --- [nio-8082-exec-1] os.web.servlet.DispatcherServlet:在 10 毫秒内完成初始化
现在尝试连接到 Share Point 并上传 testing_123.pdf,请稍候...
站点的 ID 是:siteid-site-id-sharepoint-siteid
上传文件时出错:上传会话失败太多次。
但是当我尝试使用 Site.ReadWrite.All 应用程序权限时,这种方法非常适合上传。有谁知道如何解决这个问题?要求是只允许使用 Site.Selected 而不是其他权限。
【问题讨论】:
标签: java azure sharepoint microsoft-graph-api