Example #1
0
        /// <summary>
        /// Initializes a new instance based on the specified <paramref name="refreshToken"/>.
        /// </summary>
        /// <param name="clientId">The client ID.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="refreshToken">The refresh token of the user.</param>
        /// <returns>The created instance of <see cref="Skybrud.Social.Spotify.SpotifyService" />.</returns>
        public static SpotifyService CreateFromRefreshToken(string clientId, string clientSecret, string refreshToken)
        {
            if (String.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (String.IsNullOrWhiteSpace(clientSecret))
            {
                throw new ArgumentNullException(nameof(clientSecret));
            }
            if (String.IsNullOrWhiteSpace(refreshToken))
            {
                throw new ArgumentNullException(nameof(refreshToken));
            }

            // Initialize a new OAuth client
            SpotifyOAuthClient client = new SpotifyOAuthClient(clientId, clientSecret);

            // Get an access token from the refresh token.
            SpotifyTokenResponse response = client.GetAccessTokenFromRefreshToken(refreshToken);

            // Update the OAuth client with the access token
            client.AccessToken = response.Body.AccessToken;

            // Initialize a new service instance
            return(new SpotifyService(client));
        }
Example #2
0
 /// <summary>
 /// Initialize a new service instance from the specified OAuth <paramref name="client"/>.
 /// </summary>
 /// <param name="client">The OAuth client.</param>
 /// <returns>The created instance of <see cref="Skybrud.Social.Spotify.SpotifyService" />.</returns>
 public static SpotifyService CreateFromOAuthClient(SpotifyOAuthClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     return(new SpotifyService(client));
 }
Example #3
0
 private SpotifyService(SpotifyOAuthClient client)
 {
     Client  = client;
     Albums  = new SpotifyAlbumsEndpoint(this);
     Artists = new SpotifyArtistsEndpoint(this);
     Player  = new SpotifyPlayerEndpoint(this);
     Tracks  = new SpotifyTracksEndpoint(this);
     Users   = new SpotifyUsersEndpoint(this);
 }
 internal SpotifyAlbumsRawEndpoint(SpotifyOAuthClient client)
 {
     Client = client;
 }
Example #5
0
 internal SpotifyUsersRawEndpoint(SpotifyOAuthClient client)
 {
     Client = client;
 }
Example #6
0
 internal SpotifyPersonalizationRawEndpoint(SpotifyOAuthClient client)
 {
     Client = client;
 }
Example #7
0
 internal SpotifyArtistsRawEndpoint(SpotifyOAuthClient client)
 {
     Client = client;
 }
 internal SpotifyPlayerRawEndpoint(SpotifyOAuthClient client)
 {
     Client = client;
 }
Example #9
0
 internal SpotifyTracksRawEndpoint(SpotifyOAuthClient client)
 {
     Client = client;
 }