Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
        public async Task <string> GetGraphTokenAsync()
        {
            var token = await authProvider.GetTokenOnBehalfOfAsync();

            return(token);
        }