Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
Hello,
I wrote a Python script to update playlists (throught API calls). It works fine, but I have to generate a new token each hour from the Spotify Web API Console. Is there a way to get a permanent token in order to be able to use it in a scheduled script ?
Thanks,
Rémy
Hi Remy,
when requesting the Access Token you will also get a Refresh Token . With the Refresh Token you can generate a new Access Token if it has expired, this does not need user intervention
Kind Regards
.
Hi ffkangoroo,
I've seen this notion of "refresh token" in the documentation. But I don't know which API call to do to refresh a token received by the "Spotify Web API Console".
Could you give me an example of an API call ?
Thanks,
Rémy
Sure 🙂
This is described here: Code Flow Guide
There you will find the following Example (with the refresh_token beeing provided through the route in your app you could have stored it in the Database.):
Example
The following example retrieves a refreshed Access Token once the current one has expired:
app.get('/refresh_token', function(req, res) { var refresh_token = req.query.refresh_token; var authOptions = { url: 'https://accounts.spotify.com/api/token', headers: { 'Authorization': 'Basic ' + (new Buffer(client_id + ':' + client_secret).toString('base64')) }, form: { grant_type: 'refresh_token', refresh_token: refresh_token }, json: true }; request.post(authOptions, function(error, response, body) { if (!error && response.statusCode === 200) { var access_token = body.access_token; res.send({ 'access_token': access_token }); } }); });
The response will be similar to this:
{ "access_token": "NgA6ZcYI...ixn8bUQ", "token_type": "Bearer", "scope": "user-read-private user-read-email", "expires_in": 3600 }
Hi,
A simple Node.js application to get a refresh token throught the authorization code flow.
https://github.com/rmjstn/spotify-refresh-token
Rémy
Hey there you, Yeah, you! 😁 Welcome - we're glad you joined the Spotify Community! While you here, let's have a fun game…