public SpotifyClient(string clientId, string clientSecret, string redirectUrl) { this.clientId = clientId; this.clientSecret = clientSecret; this.redirectUrl = redirectUrl; httpClient = new HttpClient(); authenticationType = SpotifyConstants.AuthenticationType.None; }
public async Task <string> Authenticate(string accessToken, DateTimeOffset accessTokenExpiresAt, string refreshToken) { AccessToken = accessToken; AccessTokenExpiresAt = accessTokenExpiresAt; RefreshToken = refreshToken; authenticationType = SpotifyConstants.AuthenticationType.AuthorizationCode; return(await RefreshAccessToken()); }
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)); }
public async Task <string> RefreshAccessToken(string refreshToken) { authenticationType = SpotifyConstants.AuthenticationType.AuthorizationCode; RefreshToken = refreshToken; return(await RefreshAccessToken()); }