2 Commits

Author SHA1 Message Date
FrigaT
34261d02a9 Авторизация через паспорт
All checks were successful
Release / pack-and-publish (release) Successful in 31s
2026-04-20 15:58:27 +03:00
FrigaT
5f761d4fe8 Добавлена авторизация через паспорт 2026-04-20 15:56:38 +03:00
2 changed files with 12 additions and 1 deletions

View File

@@ -45,7 +45,7 @@ public class YUserAPI : YCommonAPI
Api.Storage.AccessToken = accessToken;
Api.Storage.Token = accessToken.AccessToken;
await AuthorizeAsync(accessToken.AccessToken);
await AuthorizeByPassportAsync(accessToken.AccessToken);
return true;
}
@@ -63,6 +63,16 @@ public class YUserAPI : YCommonAPI
Api.Storage.SetAuthorized(authInfo.Account, token);
}
public async Task AuthorizeByPassportAsync(string token)
{
if (string.IsNullOrEmpty(token))
throw new Exception("Токен не может быть пустым");
Api.Storage.Token = token;
await GetAccessTokenAsync();
await AuthorizeAsync(Api.Storage.Token);
}
public Task<YAccountResult?> GetUserAuthAsync()
=> new YGetAuthInfoBuilder(Api).ExecuteAsync(null!);

View File

@@ -8,6 +8,7 @@ namespace YandexMusic.API.Requests.Account;
internal class YGetMusicTokenBuilder : YAuthRequestBuilder<YAccessToken?, object>
{
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(object _)