From 76630bf268d856517b8398e0662485a0828828c5 Mon Sep 17 00:00:00 2001 From: Philip Webb Date: Thu, 28 May 2026 13:19:20 +0100 Subject: [PATCH 1/2] Altered the ICommonData interface to include a NestedLoginTokenPropertyName to fit the new response shape. SpondClient Login method was updated to use the NestedLoginTokenPropertyName if using the original LoginTokenPropertyName returned an Object from the response JSON. --- Spond.API/Interfaces/ICommonData.cs | 7 ++++++- Spond.API/Models/CommonData.2.1.cs | 2 ++ Spond.API/Models/CommonData.Core.V1.cs | 6 ++++-- Spond.API/Services/SpondClient.cs | 4 ++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Spond.API/Interfaces/ICommonData.cs b/Spond.API/Interfaces/ICommonData.cs index dd529c3..755f06d 100644 --- a/Spond.API/Interfaces/ICommonData.cs +++ b/Spond.API/Interfaces/ICommonData.cs @@ -9,7 +9,12 @@ public interface ICommonData /// Gets the name of the login token property in the API response. /// string LoginTokenPropertyName { get; } - + + /// + /// Gets the name of the login token property in the API response if the token is wrapped in an object. + /// + string NestedLoginTokenPropertyName { get; } + /// /// Gets the base URL for the Spond API. /// diff --git a/Spond.API/Models/CommonData.2.1.cs b/Spond.API/Models/CommonData.2.1.cs index 03b486d..43cb235 100644 --- a/Spond.API/Models/CommonData.2.1.cs +++ b/Spond.API/Models/CommonData.2.1.cs @@ -12,6 +12,8 @@ internal class CommonData_2_1 : ICommonData /// public string LoginTokenPropertyName => "loginToken"; /// + public string NestedLoginTokenPropertyName => "token"; + /// public string BaseUrl => "https://spond.com/"; /// public string LoginUrl => "/api/2.1/login"; diff --git a/Spond.API/Models/CommonData.Core.V1.cs b/Spond.API/Models/CommonData.Core.V1.cs index e345dea..bb2bb76 100644 --- a/Spond.API/Models/CommonData.Core.V1.cs +++ b/Spond.API/Models/CommonData.Core.V1.cs @@ -10,11 +10,13 @@ namespace Spond.API.Models; internal class CommonData_Core_V1 : ICommonData { /// - public string LoginTokenPropertyName => "loginToken"; + public string LoginTokenPropertyName => "accessToken.token"; + /// + public string NestedLoginTokenPropertyName => "token"; /// public string BaseUrl => "https://api.spond.com/"; /// - public string LoginUrl => "core/v1/login"; + public string LoginUrl => "/core/v1/auth2/login"; /// public string UserUrl => "core/v1/profile"; /// diff --git a/Spond.API/Services/SpondClient.cs b/Spond.API/Services/SpondClient.cs index d9d5146..1194e1f 100644 --- a/Spond.API/Services/SpondClient.cs +++ b/Spond.API/Services/SpondClient.cs @@ -102,6 +102,10 @@ private async Task Login(T loginPayload, Func>? ot // Happy path: direct login token returned (no 2FA). if (root.TryGetProperty(_commonData.LoginTokenPropertyName, out var tokenElement)) { + if(tokenElement.ValueKind == JsonValueKind.Object) + { + tokenElement.TryGetProperty(_commonData.NestedLoginTokenPropertyName, out tokenElement); + } var loginToken = tokenElement.GetString(); if (string.IsNullOrEmpty(loginToken)) { From b824eb3ee138b2bbf1cc04cebdc5b9fd59247c2a Mon Sep 17 00:00:00 2001 From: Philip Webb Date: Thu, 28 May 2026 13:49:28 +0100 Subject: [PATCH 2/2] fixed a typo in LoginTokenPropertyName --- Spond.API/Models/CommonData.Core.V1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spond.API/Models/CommonData.Core.V1.cs b/Spond.API/Models/CommonData.Core.V1.cs index bb2bb76..666a043 100644 --- a/Spond.API/Models/CommonData.Core.V1.cs +++ b/Spond.API/Models/CommonData.Core.V1.cs @@ -10,7 +10,7 @@ namespace Spond.API.Models; internal class CommonData_Core_V1 : ICommonData { /// - public string LoginTokenPropertyName => "accessToken.token"; + public string LoginTokenPropertyName => "accessToken"; /// public string NestedLoginTokenPropertyName => "token"; ///