public GraphServiceClient GetClientForApplication(string tenantId) { var authenticationContext = _adalFactory.GetAuthenticationContextForApplication(tenantId); return(new GraphServiceClient(new DelegateAuthenticationProvider(async requestMessage => { var result = await authenticationContext.AcquireTokenAsync(Resource, _clientCredential); requestMessage.Headers.Authorization = new AuthenticationHeaderValue(result.AccessTokenType, result.AccessToken); }))); }
public ActiveDirectoryClient GetClientForApplication(string tenantId) { var authenticationContext = _adalFactory.GetAuthenticationContextForApplication(tenantId); var servicePointUri = new Uri($"{Resource}{tenantId}"); return(new ActiveDirectoryClient(servicePointUri, async() => { var result = await authenticationContext.AcquireTokenAsync(Resource, _clientCredential); return result.AccessToken; })); }