From e034455173df8d97c70dfa849ce3eaa99f3c0c66 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Sat, 1 Jun 2024 12:47:36 +0600 Subject: [PATCH] chore: fix home feed not showing up --- lib/provider/authentication_provider.dart | 5 +- .../spotify_endpoints.dart | 57 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/provider/authentication_provider.dart b/lib/provider/authentication_provider.dart index c94f4f3e..be61cb4f 100644 --- a/lib/provider/authentication_provider.dart +++ b/lib/provider/authentication_provider.dart @@ -52,8 +52,9 @@ class AuthenticationCredentials { headers: { "Cookie": spDc ?? "", "User-Agent": - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" }, + validateStatus: (status) => true, ), ); final body = res.data; @@ -65,7 +66,7 @@ class AuthenticationCredentials { } return AuthenticationCredentials( - cookie: "${res.headers["set-cookie"]}; $spDc", + cookie: "${res.headers["set-cookie"]?.join(";")}; $spDc", accessToken: body['accessToken'], expiration: DateTime.fromMillisecondsSinceEpoch( body['accessTokenExpirationTimestampMs'], diff --git a/lib/services/custom_spotify_endpoints/spotify_endpoints.dart b/lib/services/custom_spotify_endpoints/spotify_endpoints.dart index 4bc78f8a..0c7daeb2 100644 --- a/lib/services/custom_spotify_endpoints/spotify_endpoints.dart +++ b/lib/services/custom_spotify_endpoints/spotify_endpoints.dart @@ -181,35 +181,36 @@ class CustomSpotifyEndpoints { 'referer': 'https://open.spotify.com/' }; final response = await _client.getUri( - Uri( - scheme: "https", - host: "api-partner.spotify.com", - path: "/pathfinder/v1/query", - queryParameters: { - "operationName": "home", - "variables": jsonEncode({ - "timeZone": tz.local.name, - "sp_t": spTCookie, - "country": country.name, - "facet": null, - "sectionItemsLimit": 10 - }), - "extensions": jsonEncode( - { - "persistedQuery": { - "version": 1, + Uri( + scheme: "https", + host: "api-partner.spotify.com", + path: "/pathfinder/v1/query", + queryParameters: { + "operationName": "home", + "variables": jsonEncode({ + "timeZone": tz.local.name, + "sp_t": spTCookie, + "country": country.name, + "facet": null, + "sectionItemsLimit": 10 + }), + "extensions": jsonEncode( + { + "persistedQuery": { + "version": 1, - /// GraphQL persisted Query hash - /// This can change overtime. We've to lookout for it - /// Docs: https://www.apollographql.com/docs/graphos/operations/persisted-queries/ - "sha256Hash": - "eb3fba2d388cf4fc4d696b1757a58584e9538a3b515ea742e9cc9465807340be", - } - }, - ), - }, - ), - options: Options(headers: headers)); + /// GraphQL persisted Query hash + /// This can change overtime. We've to lookout for it + /// Docs: https://www.apollographql.com/docs/graphos/operations/persisted-queries/ + "sha256Hash": + "eb3fba2d388cf4fc4d696b1757a58584e9538a3b515ea742e9cc9465807340be", + } + }, + ), + }, + ), + options: Options(headers: headers), + ); final data = SpotifyHomeFeed.fromJson( transformHomeFeedJsonMap(response.data),