Ejemplo n.º 1
0
 public SpotifyService(IClient webClient, ITrackRepository trackRepository, IGenreRepository genreRepository)
 {
     _urlToken        = "https://accounts.spotify.com/api/token";
     _authentication  = new SpotifyAuthentication("b1147fe5ecdf4407a778d5af85728d6b", "5b7a0f78a40141779d0ec3421b00e913", "Bearer");
     _webClient       = webClient;
     _trackRepository = trackRepository;
     _genreRepository = genreRepository;
 }
Ejemplo n.º 2
0
        public SpotifyAuthentication GenerateAuthentication()
        {
            var auth = new SpotifyAuthentication
            {
                ClientId     = clientId,
                ClientSecret = clientSecret
            };

            return(auth);
        }
Ejemplo n.º 3
0
        public Spotify(IConfiguration config)
        {
            _config = config;

            SpotifyAuthentication token = new SpotifyAuthentication(_config);
            var bearer = JsonConvert.DeserializeObject <Dictionary <string, string> >(token.GetClientCredentialsAuthToken());

            _api = new SpotifyWebAPI
            {
                AccessToken = bearer["access_token"],
                TokenType   = bearer["token_type"]
            };
        }
Ejemplo n.º 4
0
 public SpotifySortWorker(ILogger <SpotifySortWorker> logger,
                          IOptions <SpotifySortOptions> sortOptions,
                          IOptions <SpotifyAuthentication> authOptions,
                          ISpotifySort sorter,
                          IServiceScopeFactory scopeFactory)
 {
     this.logger       = logger;
     this.sortOptions  = sortOptions.Value;
     this.authOptions  = authOptions.Value;
     this.sorter       = sorter;
     this.localIp      = this.authOptions.CallbackIp;
     this.semaphore    = new SemaphoreSlim(1, 1);
     this.scopeFactory = scopeFactory;
 }
Ejemplo n.º 5
0
        public IActionResult OnGet()
        {
            AuthenticationObject = _context.AuthenticationObjects.FirstOrDefault();

            if (AuthenticationObject != null)
            {
                return(RedirectToPage("../PlaylistRequest/Create"));
            }

            if (!string.IsNullOrEmpty(code))
            {
                if (AuthenticationObject == null)
                {
                    SpotifyAuthentication.ExchangeCodeForToken(code, _context);
                }

                return(RedirectToPage("../PlaylistRequest/Create"));
            }

            return(Page());
        }
Ejemplo n.º 6
0
        public void OnPost()
        {
            var authTokenUrl = SpotifyAuthentication.GetAuthenticationTokenURL();

            Response.Redirect(authTokenUrl);
        }