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);
}
}
}