使用新的 microsoft-graph-auth 库 java sdk 会出现未经授权的错误

Using new microsoft-graph-auth library java sdk gives unauthorized error

Permissions in azure portal I am trying to use microsoft graph auth library preview. Microsoft-graph-auth-sdk-java 我可以初始化 graphClient 但无法获取 data.I 未授权 401。

"code": "InvalidAuthenticationToken", "message": "CompactToken parsing failed with error code: 80049217",

 List<String> scopes = new ArrayList<String>();
    scopes.add("User.Read.All");

ClientCredentialProvider authProvider = new ClientCredentialProvider(app-Id, 
            scopes_list,
            client-Secret,
            tenantId, NationalCloud.Global);

IgraphClient graphClient = GraphServiceClient.builder().authenticationProvider(authProvider).logger(logger)
                .buildClient();

IUserCollectionPage users = graphClient.users()
            .buildRequest()
            .get();
    List<User> usersList = users.getCurrentPage();
    for(User user : usersList) {
        System.out.println(user.displayName);
    }

Permissions picture Link

要使用客户端凭据进行仅限应用程序的调用,您需要传递范围“https://graph.microsoft.com/.default”,然后在应用程序注册门户中授予管理员对 User.Read.All 的同意。

权限和代码没问题。问题一定出在库上,因为它在快照中。但我猜他们最近做了一些改变,可以解决你面临的问题。尝试从项目中重新构建 jar。