diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 26a5be2..0000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/Auth/LoginViaCustomRequest.cs b/Auth/LoginViaCustomRequest.cs
new file mode 100644
index 0000000..3638ceb
--- /dev/null
+++ b/Auth/LoginViaCustomRequest.cs
@@ -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; }
+
+}
diff --git a/Auth/LoginViaCustomResponse.cs b/Auth/LoginViaCustomResponse.cs
new file mode 100644
index 0000000..560f69d
--- /dev/null
+++ b/Auth/LoginViaCustomResponse.cs
@@ -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; }
+
+}
diff --git a/RudderApiException.cs b/Exceptions/RudderApiException.cs
similarity index 100%
rename from RudderApiException.cs
rename to Exceptions/RudderApiException.cs
diff --git a/RudderAuthException.cs b/Exceptions/RudderAuthException.cs
similarity index 100%
rename from RudderAuthException.cs
rename to Exceptions/RudderAuthException.cs
diff --git a/RudderNetworkException.cs b/Exceptions/RudderNetworkException.cs
similarity index 100%
rename from RudderNetworkException.cs
rename to Exceptions/RudderNetworkException.cs
diff --git a/RudderNotFoundException.cs b/Exceptions/RudderNotFoundException.cs
similarity index 100%
rename from RudderNotFoundException.cs
rename to Exceptions/RudderNotFoundException.cs
diff --git a/RudderRateLimitException.cs b/Exceptions/RudderRateLimitException.cs
similarity index 100%
rename from RudderRateLimitException.cs
rename to Exceptions/RudderRateLimitException.cs
diff --git a/Services/AuthService.cs b/Services/AuthService.cs
index 766fd09..d755693 100644
--- a/Services/AuthService.cs
+++ b/Services/AuthService.cs
@@ -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;
+ }
+
+ ///
+ /// Signs the player in through the project's custom authorization webhook.
+ /// The returned token pair is stored in the configured token store.
+ ///
+ public async Task LoginWithCustomAsync(
+ JToken customData,
+ string region,
+ string language,
+ string? nickname = null,
+ CancellationToken cancellationToken = default)
+ {
+ var response = await _client.SendAsync(
+ "POST",
+ "/sdk/v1/authorization/custom",
+ new LoginViaCustomRequest
+ {
+ Key = _client.ProjectKey,
+ CustomData = customData,
+ Region = region,
+ Language = language,
+ Nickname = nickname
},
cancellationToken).ConfigureAwait(false);