0
我正在试图在使用this .Net Wrapper/API的C#表单中使用Spotify的Web API。Spotify API访问和刷新令牌
我想创建一个表单,用户可以输入他的用户名和密码,然后程序创建一个播放列表(使用授权码流),但我在验证失败。我在Web Api网站上创建了一个项目并保存了我的ClientID和ClientSecret,但是如何获取访问令牌和刷新令牌?该API没有提供这方面的例子,我无法找到解决方案。
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);
}
}
}