26 lines
1022 B
C#
26 lines
1022 B
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using YandexMusic.API.Models.Account;
|
|
using YandexMusic.API.Requests.Common;
|
|
|
|
namespace YandexMusic.API.Requests.Passport;
|
|
|
|
internal class YGetMusicTokenBuilder : YPassportRequestBuilder<YAccessToken?, string>
|
|
{
|
|
public YGetMusicTokenBuilder(YandexMusicApi api) : base(api) { }
|
|
protected override string BaseUrl => YConstants.Endpoints.MobilePassportUrl;
|
|
protected override string Method => WebRequestMethods.Http.Post;
|
|
protected override string PathTemplate => "/1/token";
|
|
protected override HttpContent? GetContent(string passportToken)
|
|
=> new FormUrlEncodedContent(new Dictionary<string, string>
|
|
{
|
|
{ "client_id", YConstants.ClientId },
|
|
{ "client_secret", YConstants.ClientSecret },
|
|
{ "grant_type", "x-token" },
|
|
{ "access_token", passportToken }
|
|
});
|
|
protected override void SetCustomHeaders(HttpRequestHeaders headers)
|
|
{
|
|
headers.Remove("Authorization");
|
|
}
|
|
} |