有人可以告诉我,在 2020 年 10 月 13 日之后是否仍然可以使用 MS Graph 的以下身份验证方法?
public static async Task<string> GetUserAccessTokenAsync()
{
String APIToken = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX";
String LoginMail = "xxx@xxx.be";
String LoginWachtwoord = "xxxxxxxxxxx";
UserPasswordCredential userPasswordCredential = new UserPasswordCredential(LoginMail, LoginWachtwoord);
AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/diekeure.be");
//Console App for Microsoft Graph
AuthenticationResult token = await authContext.AcquireTokenAsync("https://graph.microsoft.com/", APIToken, userPasswordCredential);
return token.AccessToken;
} /* GetUserAccessTokenAsync */
public static GraphServiceClient GetAuthenticatedClient()
{
GraphServiceClient graphClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
async (requestMessage) => {
string accessToken = await GetUserAccessTokenAsync();
// Append the access token to the request.
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
}));
return graphClient;
} /* GetAuthenticatedClient */
-> await graphClient....
Nuget 包:Microsoft.IdentityModel.Clients.ActiveDirectory v3.19.8
我也不确定这是否行不通