sdk: LoginWithCustomAsync + regenerated auth models
CI / check (push) Successful in 58s
CI / publish (push) Has been skipped

This commit is contained in:
edmand46
2026-08-28 13:36:12 +03:00
parent d4bbafb314
commit 3c590294c9
9 changed files with 72 additions and 1 deletions
+34 -1
View File
@@ -1,6 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using RudderSdk.Core.Models.Auth;
namespace RudderSdk.Core;
@@ -41,7 +42,39 @@ public sealed class AuthService
DeviceId = _client.DeviceIdProvider.DeviceId,
Region = region,
Language = language,
Nickname = nickname!
Nickname = nickname
},
cancellationToken).ConfigureAwait(false);
if (response == null || string.IsNullOrEmpty(response.AccessToken) || string.IsNullOrEmpty(response.RefreshToken))
throw new InvalidOperationException("The server returned an incomplete session.");
_client.TokenStore.SaveTokens(response.AccessToken, response.RefreshToken);
NotifySignedIn();
return response;
}
/// <summary>
/// Signs the player in through the project's custom authorization webhook.
/// The returned token pair is stored in the configured token store.
/// </summary>
public async Task<LoginViaCustomResponse> LoginWithCustomAsync(
JToken customData,
string region,
string language,
string? nickname = null,
CancellationToken cancellationToken = default)
{
var response = await _client.SendAsync<LoginViaCustomRequest, LoginViaCustomResponse>(
"POST",
"/sdk/v1/authorization/custom",
new LoginViaCustomRequest
{
Key = _client.ProjectKey,
CustomData = customData,
Region = region,
Language = language,
Nickname = nickname
},
cancellationToken).ConfigureAwait(false);