Spotify Web API wrapper for Dot Net Standard, for use in UWP and .NET Core
Available on NuGet at
https://www.nuget.org/packages/DotNetStandardSpotifyWebApi/0.1.0
Compatible with .NET Core, ASP.NET Core, and UWP.
Todo:
Currently Implements the following endpoints:
The following endpoints are not yet implemeted:
using DotNetStandardSpotifyWebApi.Authorization;
string Client_Id = "<your client id>";
string Client_Secret = "<your client secret>";
string Redirect_URI = "<your redirect uri>";
List<SpotifyScopeEnum> Scopes = new List<SpotifyScopEnum>(){
SpotifyScopeEnum.PLAYLIST_READ_PRIVATE,
SpotifyScopeEnum.STREAMING,
SpotifyScopeEnum.USER_LIBRARY_MODIFY,
};
//Use the AuthorizationInProgress to send the redirect url to spotify and get user authentication
AuthorizationInProgress authProg = AuthorizationCodeFlow.GetAuthStateAndRedirect(Client_Id, Redirect_URI, Scopes);
//Using an OAuth token taken from the redirected url, exchange for a full authenticated credentials object
OAuthCredentials token = await AuthorizationCodeFlow.GetSpotifyTokenCredentials(OAuthToken, Client_Id, Client_Secret, Redirect_URI);
//Console.WriteLine(token.Access_token);
//> <access_token>
//Console.WriteLine(token.Refresh_token);
//> <refresh_token>
//Console.WriteLine(token.Expires_in);
//> <expires_in>
//With a refresh token
string refresh_token = "<your refresh token>";
OAuthCredentials refreshed = AuthorizationCodeFlow.RefreshAccessToken(refresh_token, Client_Id, Client_Secret);
//With an OAuthCredentials
OAuthCredentials creds = <Credentials Object with expired access token>;
creds = AuthorizationCodeFlow.RefreshAccessToken(expired, Client_Id, Client_Secret);
using DotNetStandardSpotifyWebApi.ObjectModel;
OAuthCredentials Creds = <...>;
User me = await Endpoints.GetCurrentUser(Creds.Access_token);
Track YouStreet = await Endpoints.GetATrack(Creds.Access_token, "7o5dTvQk2Nia65kASf2Ezo");
Getting a track with from a specific market. Used in track re-linking
Track DareYori = await Endpoints.GetATrack(Creds.Access_token, "4FwzvpVpgzI3tj9FHVPJQh", market="JP");
User currentUser = <...>;
string PlaylistToGet = "5XDtox3aWN1U8hczfRZuJm";
Playlist Lounge = await Endpoints.GetAPlaylist(Creds.Access_token, currentUser.Id, PlaylistToGet);
For more complete examples, see the ObjectModelTests.cs file.