Spotify API
Hey all! Need a little help fetching the track that I'm currently playing. I was going through the documentation and from what I've understood it says that the access token is valid only for one hour. I was planning to have a little section on a website I'm developing to show a "Now Playing - Spotify" section. How do I go about doing that? Thanks
6 Replies
you redo this when it expires https://developer.spotify.com/documentation/web-api/tutorials/getting-started#request-an-access-token
generally you'd either set up a catch for whatever fetch you're doing in case of a 400 error that refreshes the token and retries the request
alternatively, you check before you send to see if the access token is expired or not by just checking the time, then send the refresh request to get a new one before doing the actual request.
I guess the former would be easier
Thanks @Jochem !
np 🙂
@Jochem I've been trying to fetch the currently playing track but it keeps giving me 404: invalid username
Been stuck here from an hour. Can you help please?
probably a good idea to make a new post (this one is marked as solved) and include the code. I'll look if I can, otherwise someone else will probably be able to take a look
Oh ok