0
私は、アプリケーションのみのトークンでMS Outlook Mail RESTのベータ版を使用しようとしていますが、リクエストが期待通りに機能しません。OutlookメールREST APIのベータAPIでアプリケーション専用トークンが機能しないのはなぜですか?
たとえば、folder hierarchy synchronizationはv2.0のように動作し、アプリ専用のトークンでは機能しません。
私は、アプリケーションのみのトークンでMS Outlook Mail RESTのベータ版を使用しようとしていますが、リクエストが期待通りに機能しません。OutlookメールREST APIのベータAPIでアプリケーション専用トークンが機能しないのはなぜですか?
たとえば、folder hierarchy synchronizationはv2.0のように動作し、アプリ専用のトークンでは機能しません。
app-onlyトークンは、この要求に対してうまく機能します。あなたが得たエラーは何ですか?アプリ専用のトークンでこの要求を呼び出すために
、我々は特定のユーザーに必要な代わりの私文書で以下の要求のように:
GET https://outlook.office365.com/api/v2.0/users/userPrincipalName/MailFolders
とApp-トークンを取得するために、私は、コードを使用します以下:
public static async Task<string> GetTokenByCert(string clientId, string tenant, string certThumbprint,string resource)
{
string authority = $"https://login.windows.net/{tenant}";
X509Certificate2 cert = CertHelper.FindCert(certThumbprint);
var certCred = new ClientAssertionCertificate(clientId, cert);
var authContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority);
AuthenticationResult result = null;
try
{
result = await authContext.AcquireTokenAsync(resource, certCred);
}
catch (Exception ex)
{
}
return result.AccessToken;
}