I'm trying to use Spotify's Web API in a C# Form using this .Net Wrapper/API.
I want to create a Form where the user is able to enter his Username and Password and then the Program creates him a Playlist (using the Authorization Code Flow), but I'm failing at the authentication. I created a Project on the Web Api site and saved my ClientID and ClientSecret, but how would I get the access token and the refresh token? The API doesn't provide a example on this and I wasn't able to find a solution.
using SpotifyWebAPI;
using System;
using System.Windows.Forms;
namespace Spotify_Extender
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
initialize();
}
private async void initialize()
{
var AuthenticationToken = new AuthenticationToken()
{
AccessToken = "",
ExpiresOn = DateTime.Now.AddSeconds(3600),
RefreshToken = "",
TokenType = "Bearer"
};
// In a example the guy who made the API uses the Auth-Token to get the User,
// so i assume up there you have to combine your clientToken with the credentials
// or something like that
var user = await SpotifyWebAPI.User.GetCurrentUserProfile(AuthenticationToken);
MessageBox.Show(user.EmailAddress);
var playlists = await user.GetPlaylists(AuthenticationToken);
}
}
}