public async Task TestAccessTokenApiClient() { var client = new AccessTokenApiClient("http://localhost/connect/token"); var ex = Assert.ThrowsAsync <InvalidOperationException>(() => client.GetClientCredentialsTokenAsync("test", "test", "test")); Assert.NotNull(ex); }
public static IServiceCollection AddAccessTokenManager(this IServiceCollection services, IConfiguration config) { TokenManagerOptions options = new TokenManagerOptions(); config.Bind("TokenManagerOptions", options); services.TryAddSingleton(options); var apiClient = new AccessTokenApiClient(config.GetValue <string>("TokenManagerOptions:TokenEndpoint")); services.TryAddSingleton <IAccessTokenApiClient>(apiClient); services.TryAddSingleton <IAccessTokenManager, AccessTokenManager>(); services.TryAddTransient <TokenManagerAuthenticationHandler>(); return(services); }