Je suis en train d'accéder au serveur Web géré API (Souscrire aux notifications push) avec OAuth comme ci-dessous:401 non autorisés tout en souscrivant à des notifications push avec service d'échange et OAuth
var authenticationTask = await authenticationContext.AcquireTokenAsync("https://outlook.office365.com", new ClientCredential(clientID, clientSecret));
string targetSmtp = "[email protected]";
ExchangeService exchangeService = new ExchangeService(ExchangeVersion.Exchange2013);
exchangeService.Url = someURL;
exchangeService.TraceEnabled = true;
exchangeService.TraceFlags = TraceFlags.All;
exchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, "[email protected]");
exchangeService.HttpHeaders.Add("X-AnchorMailbox", targetSmtp);
exchangeService.Credentials = new OAuthCredentials(authenticationTask.AccessToken);
PushSubscription subscription = exchangeService.SubscribeToPushNotifications(
new[] { someFolder },
new Uri(postBackUrl),
15,
null,
EventType.NewMail,
EventType.Created,
EventType.Deleted,
EventType.Modified,
EventType.Moved,
EventType.Copied);
Je suis en mesure d'obtenir le jeton pour mon application, mais tout en souscrivant à l'utilisateur ([email protected]) pour les notifications push je reçois "The request failed. The remote server returned an error: (401) Unauthorized."
erreur
Mise à jour: essayé suivant exactement le même pas mentionné ici: Azure AD app-only access tokens for exchange impersonation mais toujours obtenir 401.