Полный рефакторинг api. Вынесено отдельно api passport

This commit is contained in:
2026-04-20 23:30:01 +03:00
parent 34261d02a9
commit eb1eba0162
61 changed files with 1074 additions and 640 deletions

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