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
Vendored
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
// Code generated by apigen. DO NOT EDIT.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace RudderSdk.Core.Models.Auth;
public class LoginViaCustomRequest
{
[JsonProperty("customData")]
public JToken? CustomData { get; set; }
[JsonProperty("key")]
public string? Key { get; set; }
[JsonProperty("language")]
public string? Language { get; set; }
[JsonProperty("nickname")]
public string? Nickname { get; set; }
[JsonProperty("region")]
public string? Region { get; set; }
}
+14
View File
@@ -0,0 +1,14 @@
// Code generated by apigen. DO NOT EDIT.
using Newtonsoft.Json;
namespace RudderSdk.Core.Models.Auth;
public class LoginViaCustomResponse
{
[JsonProperty("accessToken")]
public string? AccessToken { get; set; }
[JsonProperty("refreshToken")]
public string? RefreshToken { get; set; }
}
+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);