// Get an authenticated Microsoft Graph Service client. public GraphServiceClient GetAuthenticatedClient() { graphClient = new GraphServiceClient(new DelegateAuthenticationProvider( async requestMessage => { // Passing tenant ID to the sample auth provider to use as a cache key var accessToken = await authProvider.GetTokenOnBehalfOfAsync(); // Append the access token to the request requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); })); return(graphClient); }
public async Task <string> GetGraphTokenAsync() { var token = await authProvider.GetTokenOnBehalfOfAsync(); return(token); }