<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use API token refresh from my web app (newbie) in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/How-to-use-API-token-refresh-from-my-web-app-newbie/m-p/5401235#M4970</link>
    <description>&lt;P&gt;There are two values you would get when you were trying to login to get your first token, access_token and refresh_token. You can either call setTimeout with 60000ms which includes a callback function to call a web api with your refresh_token.&lt;BR /&gt;&lt;BR /&gt;There is an example which is written by JavaScript, but it should be similar to Curl. Or you can refresh your token by refresh_token when you got the status code is 401 (which means the access_token was expired).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it could answer your problem&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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 &amp;amp;&amp;amp; response.statusCode === 200) {
      var access_token = body.access_token;
    }
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jul 2022 10:32:46 GMT</pubDate>
    <dc:creator>kw0006667</dc:creator>
    <dc:date>2022-07-04T10:32:46Z</dc:date>
    <item>
      <title>How to use API token refresh from my web app (newbie)</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/How-to-use-API-token-refresh-from-my-web-app-newbie/m-p/5398035#M4924</link>
      <description>&lt;P&gt;Hello, I'm not a pro developer but am skilled enough to be running API calls to collect ISRC codes for tracklists for a community-based online radio station.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've gotten it all working, requesting a token and running queries with it. My confusion is how to refresh the token after 60 mins. I've looked at the Token Swap and Refresh topic but it seems to have something to do with iOS-SDK (I have a Perl-based web app) and I don't understand how to do this even using Curl. My app does capture the 401 error when the token is expired but I don't know how to refresh it without telling the user to manually request a new token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers and guidance appreciated. Sorry if this is a naive question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks, Scott&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 19:52:00 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/How-to-use-API-token-refresh-from-my-web-app-newbie/m-p/5398035#M4924</guid>
      <dc:creator>Slugger415</dc:creator>
      <dc:date>2022-06-25T19:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use API token refresh from my web app (newbie)</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/How-to-use-API-token-refresh-from-my-web-app-newbie/m-p/5401235#M4970</link>
      <description>&lt;P&gt;There are two values you would get when you were trying to login to get your first token, access_token and refresh_token. You can either call setTimeout with 60000ms which includes a callback function to call a web api with your refresh_token.&lt;BR /&gt;&lt;BR /&gt;There is an example which is written by JavaScript, but it should be similar to Curl. Or you can refresh your token by refresh_token when you got the status code is 401 (which means the access_token was expired).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it could answer your problem&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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 &amp;amp;&amp;amp; response.statusCode === 200) {
      var access_token = body.access_token;
    }
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 10:32:46 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/How-to-use-API-token-refresh-from-my-web-app-newbie/m-p/5401235#M4970</guid>
      <dc:creator>kw0006667</dc:creator>
      <dc:date>2022-07-04T10:32:46Z</dc:date>
    </item>
  </channel>
</rss>

