Полный рефакторинг api. Вынесено отдельно api passport
This commit is contained in:
26
YandexMusic.API/Requests/Passport/YGetMusicTokenBuilder.cs
Normal file
26
YandexMusic.API/Requests/Passport/YGetMusicTokenBuilder.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user