mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix Spotify token endpoint - add required query params and fix cookie handling
This commit is contained in:
@@ -28,7 +28,7 @@ public class SpotifyApiClient : IDisposable
|
|||||||
// Spotify API endpoints
|
// Spotify API endpoints
|
||||||
private const string OfficialApiBase = "https://api.spotify.com/v1";
|
private const string OfficialApiBase = "https://api.spotify.com/v1";
|
||||||
private const string WebApiBase = "https://api-partner.spotify.com/pathfinder/v1";
|
private const string WebApiBase = "https://api-partner.spotify.com/pathfinder/v1";
|
||||||
private const string TokenEndpoint = "https://open.spotify.com/get_access_token";
|
private const string TokenEndpoint = "https://open.spotify.com/get_access_token?reason=transport&productType=web_player";
|
||||||
|
|
||||||
// Web API access token (obtained via session cookie)
|
// Web API access token (obtained via session cookie)
|
||||||
private string? _webAccessToken;
|
private string? _webAccessToken;
|
||||||
@@ -99,14 +99,14 @@ public class SpotifyApiClient : IDisposable
|
|||||||
|
|
||||||
_logger.LogDebug("Fetching new Spotify web access token");
|
_logger.LogDebug("Fetching new Spotify web access token");
|
||||||
|
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, TokenEndpoint);
|
// The cookie is already set in the CookieContainer during client construction
|
||||||
request.Headers.Add("Cookie", $"sp_dc={_settings.SessionCookie}");
|
// No need to manually add Cookie header - HttpClient will handle it
|
||||||
|
var response = await _webApiClient.GetAsync(TokenEndpoint, cancellationToken);
|
||||||
var response = await _webApiClient.SendAsync(request, cancellationToken);
|
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
_logger.LogError("Failed to get Spotify access token: {StatusCode}", response.StatusCode);
|
var errorBody = await response.Content.ReadAsStringAsync(cancellationToken);
|
||||||
|
_logger.LogError("Failed to get Spotify access token: {StatusCode} - {Body}", response.StatusCode, errorBody);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user