/// <summary> /// The SpotifyClient has a dependency on the userId of the user that sent a message. /// So, we create the client at runtime with a factory. /// </summary> public SpotifyClientFactory( IAuthorizationTokenRepository authorizationTokenRepository, IMapper mapper, IOptions <SpotifyOptions> spotifyOptions) { _authorizationTokenRepository = authorizationTokenRepository; _mapper = mapper; _spotifyOptions = spotifyOptions.Value; }
public SpotifyController(SpotifyOptions spotify) { Spotify = spotify; HttpClient = new HttpClient { BaseAddress = new Uri(Spotify.BaseUrl), Timeout = TimeSpan.FromSeconds(Spotify.TimeoutSeconds) }; }
public AuthorizationService( IAuthorizationTokenRepository authorizationTokenRepository, ILoginRequestService loginRequestService, IMapper mapper, IOptions <SpotifyOptions> spotifyOptions, IOptions <AzureOptions> azureOptions) { _authorizationTokenRepository = authorizationTokenRepository; _loginRequestService = loginRequestService; _mapper = mapper; _spotifyOptions = spotifyOptions.Value; _azureOptions = azureOptions.Value; }
public virtual void TestInitialize() { var services = new ServiceCollection(); this.Clock = new ClockStub(); services.AddSingleton <ISystemClock>(this.Clock); this.AuthenticationManager = new AuthenticationManagerStub(); services.AddSingleton <IAuthenticationManager>(this.AuthenticationManager); var httpContextAccessor = new HttpContextAccessorStub(); services.AddSingleton <IHttpContextAccessor>(httpContextAccessor); var options = new SpotifyOptions { ClientId = ClientId, ClientSecret = ClientSecret, }; var optionsSnapshotMock = new Mock <IOptionsSnapshot <SpotifyOptions> >(); optionsSnapshotMock.Setup(x => x.Value).Returns(options); services.AddSingleton(optionsSnapshotMock.Object); this.MockHttp = new MockHttpMessageHandler(); var builder = services.AddHttpClient("TestClient"); builder .ConfigurePrimaryHttpMessageHandler(() => this.MockHttp); builder .AddSpotifyAuthorizationCodeFlow() .ConfigureTokenHttpClientBuilder(b => b.ConfigurePrimaryHttpMessageHandler(() => this.MockHttp)); this.serviceProvider = services.BuildServiceProvider(); httpContextAccessor.ServiceProvider = this.serviceProvider; this.TestClient = this.serviceProvider.GetRequiredService <IHttpClientFactory>().CreateClient("TestClient"); }
public SpotifyService(IOptions <SpotifyOptions> options, IHttpClientFactory httpClientFactory) { _httpClientFactory = httpClientFactory; _options = options.Value; }
public ExternalAccountRepository(BotContext botContext, AesCryptography aes, IOptions <SpotifyOptions> options) { _botContext = botContext; _aes = aes; _options = options.Value; }
public LinkSpotifyModel(IOptions <SpotifyOptions> options, IExternalAccountRepository externalAccountRepository) { _externalAccountRepository = externalAccountRepository; _options = options.Value; }