Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Spond.API/Interfaces/ICommonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ public interface ICommonData
/// Gets the name of the login token property in the API response.
/// </summary>
string LoginTokenPropertyName { get; }


/// <summary>
/// Gets the name of the login token property in the API response if the token is wrapped in an object.
/// </summary>
string NestedLoginTokenPropertyName { get; }

/// <summary>
/// Gets the base URL for the Spond API.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Spond.API/Models/CommonData.2.1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ internal class CommonData_2_1 : ICommonData
/// <inheritdoc/>
public string LoginTokenPropertyName => "loginToken";
/// <inheritdoc/>
public string NestedLoginTokenPropertyName => "token";
/// <inheritdoc/>
public string BaseUrl => "https://spond.com/";
/// <inheritdoc/>
public string LoginUrl => "/api/2.1/login";
Expand Down
6 changes: 4 additions & 2 deletions Spond.API/Models/CommonData.Core.V1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ namespace Spond.API.Models;
internal class CommonData_Core_V1 : ICommonData
{
/// <inheritdoc/>
public string LoginTokenPropertyName => "loginToken";
public string LoginTokenPropertyName => "accessToken";
/// <inheritdoc/>
public string NestedLoginTokenPropertyName => "token";
/// <inheritdoc/>
public string BaseUrl => "https://api.spond.com/";
/// <inheritdoc/>
public string LoginUrl => "core/v1/login";
public string LoginUrl => "/core/v1/auth2/login";
/// <inheritdoc/>
public string UserUrl => "core/v1/profile";
/// <inheritdoc/>
Expand Down
4 changes: 4 additions & 0 deletions Spond.API/Services/SpondClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ private async Task<bool> Login<T>(T loginPayload, Func<string, Task<string>>? 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))
{
Expand Down