我正在尝试使用microsoft graph api,我需要使用该api的授权代码。在我的应用程序中,无法将应用程序重定向到microsoft登录站点。
我需要打这个电话,为此我需要authprovider:
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(authProvider)
.buildClient();
我正在使用它创建authprovider:
UsernamePasswordProvider authProvider = new UsernamePasswordProvider(CLIENT_ID,
Arrays.asList("https://graph.microsoft.com/user.read", "https://graph.microsoft.com/Mail.ReadWrite",
"https://graph.microsoft.com/Calendars.ReadWrite"),
USERNAME, PASSWORD, NationalCloud.Global,
TENANT, CLIENT_SECRET)
使用此命令时,我得到一个错误:
OAuthProblemException{error='invalid_grant', description='AADSTS65001: The user or administrator has not consented to use the application with ID 'e2bfebf6-cc77-49ec-82a3-28756ad377e5' named 'Milpitas Communications'. Send an interactive authorization request for this user and resource.
记录道id:a2b91757-4849-4680-a089-001831ef7b00相关id:ae894060-a2ce-444c-9889-96fd3cdfaea7
我还尝试使用它来创建authprovider:
AuthorizationCodeProvider authProvider = new AuthorizationCodeProvider(CLIENT_ID,
Arrays.asList("https://graph.microsoft.com/user.read", "https://graph.microsoft.com/Mail.ReadWrite",
"https://graph.microsoft.com/Calendars.ReadWrite"),
AUTHORIZATION_CODE, REDIRECT_URL, NationalCloud.Global, "common",
CLIENT_SECRET);
为了运行上面的我需要授权代码,有没有人能建议我如何在spring启动应用程序内部获取代码,因为我的应用程序不能有客户端输入(用于auth)?
或者,是否有其他方法可以使用igraphserviceclient创建日历事件?
1条答案
按热度按时间piok6c0g1#
替换
Arrays.asList("https://graph.microsoft.com/user.read", "https://graph.microsoft.com/Mail.ReadWrite", "https://graph.microsoft.com/Calendars.ReadWrite")
与Arrays.asList("https://graph.microsoft.com/.default")
可以解决此问题。我的代码供您参考: