sdk: LoginWithCustomAsync + regenerated auth models
This commit is contained in:
@@ -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; }
|
||||
|
||||
}
|
||||
@@ -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
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user