public WridoAccessTokenProvider(HttpClient client, JsonSerializer serializer, SpotifyConfiguration config, ILogger logger) { _client = client; _serializer = serializer; _config = config; _logger = logger; _authorizationTsc = new TaskCompletionSource <bool>(); _refreshToken = config.RefreshToken; if (!string.IsNullOrEmpty(_refreshToken)) { _authorizationTsc.SetResult(true); } }
private static void Main() { var spotifyConfiguration = new SpotifyConfiguration(LocalHostUrl + "spotify-callback"); var spotifyAuthenticationClient = SpotifyClientInjector.SpotifyAuthenticationClient(spotifyConfiguration); var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += RetrieveSpotifyCode; backgroundWorker.RunWorkerCompleted += OnSpotifyCodeRetrieved; backgroundWorker.RunWorkerAsync(); Process.Start(spotifyAuthenticationClient.GetAuthenticationUrl()); var counter = 0; Console.Write("Awaiting auth code "); while (code == null) { counter++; switch (counter % 4) { case 0: Console.Write("/"); counter = 0; break; case 1: Console.Write("-"); break; case 2: Console.Write("\\"); break; case 3: Console.Write("|"); break; } Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop); } Console.WriteLine($"\nGot auth code: {code}"); var spotifyCode = spotifyAuthenticationClient.GetToken(code); var spotifyApiClient = SpotifyClientInjector.SpotifyApiClient(spotifyCode); var spotifyTrack = spotifyApiClient.GetTrack("2dLQO5zSiudyseIzh5VXI7"); Console.WriteLine(spotifyTrack.PreviewUrl); Console.In.Read(); }
public Configuration(string path) { FileStream file = File.OpenRead(path); StreamReader reader = new StreamReader(file); Configuration config = JsonConvert.DeserializeObject <Configuration>(reader.ReadToEnd()); reader.Close(); file.Close(); Token = config.Token; LogLevel = config.LogLevel; Prefixes = config.Prefixes; Emojis = config.Emojis; Status = config.Status; SupportId = config.SupportId; Google = config.Google; OMDb = config.OMDb; Spotify = config.Spotify; }
public AuthenticationController(SpotifyConfiguration spotifyConfiguration, IMediator mediator) { _SpotifyConfiguration = spotifyConfiguration; _Mediator = mediator; }
public SpotifyApiController() { SpotifyConfig = new SpotifyConfiguration(); SpotifyService = new SpotifyService(); }