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
Jochem
Jochem•2y ago
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.
Satya
SatyaOP•2y ago
I guess the former would be easier Thanks @Jochem !
Jochem
Jochem•2y ago
np 🙂
Satya
SatyaOP•2y ago
@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?
Jochem
Jochem•2y ago
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
Satya
SatyaOP•2y ago
Oh ok
Want results from more Discord servers?
Add your server