You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
872 B

2 years ago
  1. using Microsoft.Graph;
  2. using System.Net.Http.Headers;
  3. namespace WebApp.Outlook
  4. {
  5. public class SDKHelper
  6. {
  7. // Get an authenticated Microsoft Graph Service client.
  8. public static GraphServiceClient AuthenticatedClient
  9. {
  10. get
  11. {
  12. var graphClient = new GraphServiceClient(
  13. new DelegateAuthenticationProvider(
  14. async (requestMessage) =>
  15. {
  16. var accessToken = await AuthProvider.AuthProvider.Instance.GetAccessTokenAsync();
  17. // Append the access token to the request.
  18. requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
  19. }));
  20. return graphClient;
  21. }
  22. }
  23. }
  24. }