/// <summary> /// Create an IAccessApiFactory using the specified Url and Token Provider /// </summary> public static IAccessApiFactory Build(string url, ITokenProvider tokenProvider) { // TokenProviderConfiguration.ApiClient is the client used by AccessApiFactory and is // NOT thread-safe, so there needs to be a separate instance for each instance of AccessApiFactory. // Do NOT cache the AccessApiFactory instances (DEV-6922) var config = new TokenProviderConfiguration(tokenProvider) { BasePath = url }; return(new AccessApiFactory(config)); }
public void CanUseTokenProviderConfiguration() { var mockTokenProvider = new Mock <ITokenProvider>(MockBehavior.Loose); // Don't care about the response // GIVEN a TokenProviderConfiguration configured with a mock TokenProvider TokenProviderConfiguration config = new TokenProviderConfiguration(mockTokenProvider.Object); // BEFORE the token is requested // THEN TokenProvider should not have been called mockTokenProvider.Verify(x => x.GetAuthenticationTokenAsync(), Times.Never); // WHEN the token is requested // THEN TokenProvider should not have been called each time var _ = config.AccessToken; mockTokenProvider.Verify(x => x.GetAuthenticationTokenAsync(), Times.Once); var __ = config.AccessToken; mockTokenProvider.Verify(x => x.GetAuthenticationTokenAsync(), Times.Exactly(2)); }
public static void Logout(this HttpResponseBase response, TokenProviderConfiguration configuration, string redirectUrl) { HttpContext.Current.GetOwinContext().Authentication.SignOut(configuration.Policy); HttpContext.Current.GetOwinContext().Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType); response.Redirect(redirectUrl); }
private AdditionalScopeHandler(IServiceProvider appApplicationServices, TokenProviderConfiguration configuration) { _configuration = configuration; }
private AdditionalScopeHandler(TokenProviderConfiguration configuration) { _configuration = configuration; }
public static string Authority(TokenProviderConfiguration configuration) => $"https://login.microsoftonline.com/tfp/{configuration.TenantId}/{configuration.Policy}/v2.0/.well-known/openid-configuration";
public CustomHttpHandler(TokenProviderConfiguration config, ITokenHandler handler) { _config = config; _handler = handler; }
public IndexModel(ITokenHandler tokenHandler, TokenProviderConfiguration config) { _tokenHandler = tokenHandler; _config = config; _client = new HttpClient(new CustomHttpHandler(config, tokenHandler)); }
private OauthAttribute(ITokenHandler iOAuthTokenProvider, TokenProviderConfiguration tokenProviderConfiguration) { _provider = iOAuthTokenProvider; _tokenProviderConfiguration = tokenProviderConfiguration; }