首页 > 解决方案 > AcquireTokenAsync 在没有有效的 cilent 密码的情况下正常工作

问题描述

我可以使用下面的代码让 AccessToken 与 MS Graph 一起使用

var credentials = new ClientCredential(accessRequest.ClientId, accessRequest.ClientSecret);
var authContext = new AuthenticationContext($"{accessRequest.Authoriy}/{accessRequest.Domain}/");
var result = await authContext.AcquireTokenAsync(accessRequest.Resource, credentials);
var graphAccess = new Library.Service.Implements.GraphCalendarService(result.AccessToken);
var mailsBox = await graphAccess.GetMailboxSettings(accessRequest.User);

这里奇怪的是第一行中使用的 [accessRequest.ClientSecret] 的值 = "qwerty"。

这是一个错误还是我需要找到另一种使用 MS Graph 的方法(条件:需要有效的 ClientId 和 ClientSecret)?

提前致谢。

标签: microsoft-graph-apiaccess-token

解决方案


推荐阅读