Open kimfucious opened 3 weeks ago
+1 here - Refreshing tokens seems at best half-baked. I've had to implement my own logic which works 90% of the time but the auto-refresh sometimes screws me over.
A flag autoRefreshToken: false
in the constructor would be a quick win personally
This is probably a dumb question, but I gotta ask:
Scenario
SpotifyApi.withUserAuthorization(...
spotify.authenticate()
which ultimately redirects to the callback URL.In the callback landing page, I can get the code from search params, which is usually used to get the _accesstoken, when using Spotify Web API directly.
Since I'm trying to use
@spotify/web-api-ts-sdk
, it would seem thatsdk.getUserToken();
The problem is that since
spotify.authenticate()
leaves the app and returns via the callback, state is lost and the sdk is not authenticated, which means thatsdk.getUserToken();
returns null.What I'm thinking is that I can use the Spotify Web API directly (not
@spotify/web-api-ts-sdk
) to do the initial auth and retrieve the access token, and then initialize the@spotify/web-api-ts-sdk
client usingconst sdk = SpotifyApi.withAccessToken(...)
and use the client@spotify/web-api-ts-sdk
going foward.The thing is that this seems overly complicated to the point where it just smells wrong.
Any advice would be most appreciated.