Beispiel #1
0
 public SpotifyClient(string clientId, string clientSecret, string redirectUrl)
 {
     this.clientId      = clientId;
     this.clientSecret  = clientSecret;
     this.redirectUrl   = redirectUrl;
     httpClient         = new HttpClient();
     authenticationType = SpotifyConstants.AuthenticationType.None;
 }
Beispiel #2
0
 public async Task <string> Authenticate(string accessToken, DateTimeOffset accessTokenExpiresAt, string refreshToken)
 {
     AccessToken          = accessToken;
     AccessTokenExpiresAt = accessTokenExpiresAt;
     RefreshToken         = refreshToken;
     authenticationType   = SpotifyConstants.AuthenticationType.AuthorizationCode;
     return(await RefreshAccessToken());
 }
Beispiel #3
0
        public async Task <string> RequestAccessToken()
        {
            FormUrlEncodedContent tokenRequestContent = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                { "grant_type", "client_credentials" }
            });

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                                                                                           SpotifyHelpers.GetEncodedAuth(clientId, clientSecret));
            HttpResponseMessage responseMessage = await httpClient.PostAsync(SpotifyConstants.RequestAccessTokenUrl,
                                                                             tokenRequestContent);

            authenticationType = SpotifyConstants.AuthenticationType.ClientCredentials;
            return(await ProcessAuthorizationResponse(responseMessage));
        }
Beispiel #4
0
 public async Task <string> RefreshAccessToken(string refreshToken)
 {
     authenticationType = SpotifyConstants.AuthenticationType.AuthorizationCode;
     RefreshToken       = refreshToken;
     return(await RefreshAccessToken());
 }