早上好
我是一个堆栈溢出的新用户,我知道这个问题不是新问题,但我没有找到解决方案。
我使用python库来调用ms图形API。
我有一个拥有O365家庭许可证的租户,我验证了Azure中的租户对于我的O365许可证是一样的。
python代码可以获取我的配置文件上的信息,但我使用"application“方法( https://graph.microsoft.com/v1.0/users/c9445de4-23db-4596-a1d3-7760dce5a3a6/drive/root )出错。
{
"error": {
"code": "BadRequest",
"message": "Tenant does not have a SPO license.",
"innerError": {
"date": "2022-02-17T10:34:31",
"request-id": "a0f521e4-d673-4856-b248-ff480a248ab9",
"client-request-id": "a0f521e4-d673-4856-b248-ff480a248ab9"
}
}
}
以及使用“委托”方法https://graph.microsoft.com/v1.0/me/drive/root
{
"error": {
"code": "BadRequest",
"message": "Tenant does not have a SPO license.",
"innerError": {
"date": "2022-02-17T11:09:33",
"request-id": "24b27408-6dfe-4612-84d9-b5c184225cdc",
"client-request-id": "24b27408-6dfe-4612-84d9-b5c184225cdc"
}
}
}
我对Java也有同样的问题:
package com.example;
import java.util.Arrays;
import java.util.List;
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.authentication.TokenCredentialAuthProvider;
import com.microsoft.graph.models.Drive;
import com.microsoft.graph.requests.GraphServiceClient;
import com.microsoft.graph.requests.UserCollectionPage;
public class App
{
public static void main( String[] args )
{
String tenant = "<my tenant>";
String clientId = "<my client>";
String clientSecret = "<my secret>";
List<String> scopes = Arrays.asList("https://graph.microsoft.com/.default");
try {
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(clientId)
.clientSecret(clientSecret)
.tenantId(tenant)
.build();
final TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(scopes, clientSecretCredential);
final GraphServiceClient graphClient = GraphServiceClient
.builder()
.authenticationProvider(tokenCredentialAuthProvider)
.buildClient();
final UserCollectionPage me = graphClient.users().buildRequest().get();
System.out.println(me.getCurrentPage().get(0).id);
final Drive result = graphClient
.users(me.getCurrentPage().get(0).id)
.drive()
.buildRequest()
.get();
System.out.println("Found Drive " + result.id);
} catch (Exception e) {
//TODO: handle exception
}
}
}
产出如下:
[ForkJoinPool.commonPool-worker-1] INFO com.azure.identity.ClientSecretCredential - Azure Identity => getToken() result for scopes [https://graph.microsoft.com/.default]: SUCCESS
c9445de4-23db-4596-a1d3-7760dce5a3a6
[ForkJoinPool.commonPool-worker-1] INFO com.azure.identity.ClientSecretCredential - Azure Identity => getToken() result for scopes [https://graph.microsoft.com/.default]: SUCCESS
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409Graph service exception Error code: BadRequest
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409Error message: Tenant does not have a SPO license.
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409GET https://graph.microsoft.com/v1.0/users/c9445de4-23db-4596-a1d3-7760dce5a3a6/drive
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409SdkVersion : graph-java/v5.14.0
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409400 : Bad Request
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409[...]
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[sendRequestInternal] - 409[Some information was truncated for brevity, enable debug logging for more details]
Feb 18, 2022 3:56:47 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: BadRequest
Error message: Tenant does not have a SPO license.
GET https://graph.microsoft.com/v1.0/users/c9445de4-23db-4596-a1d3-7760dce5a3a6/drive
SdkVersion : graph-java/v5.14.0
400 : Bad Request
[...]
[Some information was truncated for brevity, enable debug logging for more details]
谢谢你的帮助
西尔瓦诺
发布于 2022-02-18 07:21:44
您在图资源管理器中尝试过吗?如果没有,请先在图资源管理器中尝试,如果您有相同的错误,请在https://jwt.ms/上检查您的访问令牌并交叉验证您所需的权限,请按照文档检查权限- 文档,如果您有任何查询,请随时对我们作出反应?
谢谢。
https://stackoverflow.com/questions/71159101
复制相似问题