<?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: Web API Reference &amp;quot;Get Token&amp;quot; button in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5865355#M12573</link>
    <description>&lt;P&gt;Has anyone found a better solution to this? I've tried the python file that HopC posted and was able to get a token but unfortunately ran into an "insufficient scope" error. Also tried the bash script but no luck. I'm working on a project that uses a token but have similarly been having a lot of trouble with getting an access token with the new interface of the Spotify for Developers page and being able to access a token easily.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2024 00:49:55 GMT</pubDate>
    <dc:creator>fastestdudealive9</dc:creator>
    <dc:date>2024-02-05T00:49:55Z</dc:date>
    <item>
      <title>Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5528686#M8509</link>
      <description>&lt;P&gt;Overnight the entire web API reference has changed, and every page has been overhauled... to show the exact same thing... but aesthetically pleasing... so where is the "Get Token" button that manually generates an OAuth token for you to use to test the API, this button was plastered on every page of the reference, now it's missing? What is the alternative that doesn't involve me creating an entire code to fetch the token I had an easy access button for, considering it's an entire external authentication process?? There's a reason I generated it manually every hour I needed it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 14:51:12 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5528686#M8509</guid>
      <dc:creator>jootus</dc:creator>
      <dc:date>2023-03-27T14:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5529050#M8527</link>
      <description>&lt;P&gt;Spotify please fix this! I also prefer manually collecting the token when I want to update my playlist!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 03:58:39 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5529050#M8527</guid>
      <dc:creator>donsebas77</dc:creator>
      <dc:date>2023-03-28T03:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5529647#M8544</link>
      <description>&lt;P&gt;I just put this together for someone else, so happy to share code for obtaining a valid token. Happy to advise if you are not familiar with Python. Plug in your client ID/client secret and when run this will print out your token, or you can use it in whatever way you please. If you do not have software installed on your computer for editing and running code, you could quickly and easily set up a replit account to run the code whenever you need a fresh token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests, datetime

'''
Implementation of Token class for gaining, storing and verifying Spotify developer
tokens. Using text file to store; explore databases for production code.
'''

# Enter client ID and secret from developer console; store in .env or similar
# for production
CLIENT_ID = '' 
CLIENT_SECRET = ''

class Token:
    # Token class will try to load an existing saved token rather than
    # send unnecessary requests; at scale this would improve performance
    def __init__(self):
        self.__token = None
        self.__time = None
        self.load_token()
        try:
            if self.__time + datetime.timedelta(hours=1) &amp;lt; datetime.datetime.now():
                # token out of time; update
                print('Token out of time')
                self.get_token()
            else:
                print('Token up to date')

        except TypeError:
            # token time is not a datetime object; update
            print('Token time format incorrect')
            self.get_token()
        self.save_token()

    def get_token(self):
        endpoint = "https://accounts.spotify.com/api/token"
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        body = {
                "grant_type": "client_credentials",
                "client_id": CLIENT_ID,
                "client_secret": CLIENT_SECRET
            }
        response = requests.post(endpoint, headers=headers, data=body)
        self.__token = response.json()['access_token']
        self.__time = datetime.datetime.now()
        self.save_token()

    def save_token(self):
        details = self.__token + ',' + self.__time.strftime("%d-%b-%Y (%H:%M:%S.%f)")
        with open('token.txt', 'w') as file:
            file.write(details)

    def load_token(self):
        try:
            with open('token.txt', 'r') as file:
                result = file.read()
                result = result.strip().split(',')
                self.__token = result[0]
                self.__time = datetime.datetime.strptime(result[1], "%d-%b-%Y (%H:%M:%S.%f)")
        except FileNotFoundError:
            # no token file saved
            print('File not found')
            self.get_token()
        except ValueError:
            # token file corrupted
            print('File corrupt')
            self.get_token()

    def token(self):
        return self.__token

    def time(self):
        return self.__time


token = Token()

print(token.token()) # access your token&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 20:23:48 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5529647#M8544</guid>
      <dc:creator>HopC</dc:creator>
      <dc:date>2023-03-28T20:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5531353#M8577</link>
      <description>&lt;P&gt;I don't believe this method allows you to grant scopes.&amp;nbsp; Really missing this capability that Spotify has removed&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 02:15:11 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5531353#M8577</guid>
      <dc:creator>mattgreen_aus</dc:creator>
      <dc:date>2023-03-31T02:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5575643#M9087</link>
      <description>&lt;P&gt;Really miss this part, managed to get a sort of "Get Token" button behavior with the following bash script:&lt;/P&gt;&lt;PRE&gt;CLIENT_ID="..."&lt;BR /&gt;CLIENT_SECRET=".."&lt;BR /&gt;SCOPES="user-read-currently-playing,user-modify-playback-state,user-read-playback-state"&lt;BR /&gt;curl -X "POST" -H "Authorization: Basic $(echo -n "$CLIENT_ID:$CLIENT_SECRET" | base64)" -d "grant_type=client_credentials&amp;amp;scope=$SCOPES" "&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;"&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;But I have had issues with some endpoints such as me/player/next, I am getting the following response: (I am a premium user)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;"error": {&lt;BR /&gt;"status": 403,&lt;BR /&gt;"message": "Player command failed: Premium required",&lt;BR /&gt;"reason": "PREMIUM_REQUIRED"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;And it was kind of annoying to create an app for quick exploring/testing purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PLEASE BRING BACK THE BUTTON DEAR SPOTIFY &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 01:11:57 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5575643#M9087</guid>
      <dc:creator>ferchoget1</dc:creator>
      <dc:date>2023-05-05T01:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5587961#M9363</link>
      <description>&lt;P&gt;The removal of this button feels frustrating. In addition, the sample code provided in "Tutorials" on how to authorize seems to be incomplete - the node code required a few modifications to even run. Not a very beginner friendly Tutorial, especially when node is the only sample setup Spotify provides.&lt;BR /&gt;&lt;BR /&gt;On some endpoints there is a similar functionality to the old "Get Token" - e.g. on&amp;nbsp;&lt;A href="https://developer.spotify.com/documentation/web-api/reference/get-users-top-artists-and-tracks" target="_blank"&gt;https://developer.spotify.com/documentation/web-api/reference/get-users-top-artists-and-tracks&lt;/A&gt;&amp;nbsp;there is a "Try it" option that gets a token for you (and directly updates the "Sample output" to real output), but it doesnt show you the token, so this can only be used on the endpoints where the "Try it" button happens to be shown. (Idk if there is a logic to which pages have it, there might be)&lt;BR /&gt;&lt;BR /&gt;Please bring back the old way this used to work or if you have to hide the test token from the developers that are trying to work with the api make the "Try it" functionality available on all pages of the documentation!&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 14:11:47 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5587961#M9363</guid>
      <dc:creator>66DD2956-3456-4726-9</dc:creator>
      <dc:date>2023-05-28T14:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5786068#M12062</link>
      <description>&lt;P&gt;I'm a beginner. I think it is very difficult for me to get my access token. So dear Spotify, can you add the function again?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Maybe I think you could add some easer and more understandable tutorials.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2023 09:25:43 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5786068#M12062</guid>
      <dc:creator>Yemen</dc:creator>
      <dc:date>2023-12-31T09:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5865355#M12573</link>
      <description>&lt;P&gt;Has anyone found a better solution to this? I've tried the python file that HopC posted and was able to get a token but unfortunately ran into an "insufficient scope" error. Also tried the bash script but no luck. I'm working on a project that uses a token but have similarly been having a lot of trouble with getting an access token with the new interface of the Spotify for Developers page and being able to access a token easily.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2024 00:49:55 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/5865355#M12573</guid>
      <dc:creator>fastestdudealive9</dc:creator>
      <dc:date>2024-02-05T00:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/6366422#M15081</link>
      <description>&lt;P&gt;Hey! I managed to get my token using the "Try it" button and inspecting the html requests, if you wanna get your token what you have to do is open chrometools or devtools and hit the network tab, then clear all the requests, after that make sure its recording and hit the "Try it" button. Look at the first request that says api.spotify.com and double click it, then look for the request headers and boom! you got your token&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2024 15:12:17 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/6366422#M15081</guid>
      <dc:creator>Yresd</dc:creator>
      <dc:date>2024-09-22T15:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Web API Reference "Get Token" button</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/6477739#M15424</link>
      <description>&lt;P&gt;I just built a service that provides the most potent access_token's (auth code flow), either via the UI (copy and paste) or via http requests. Feel free to check it out: &lt;A href="https://spoken.host" target="_blank"&gt;https://spoken.host&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Nov 2024 15:42:23 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Web-API-Reference-quot-Get-Token-quot-button/m-p/6477739#M15424</guid>
      <dc:creator>DG9500</dc:creator>
      <dc:date>2024-11-02T15:42:23Z</dc:date>
    </item>
  </channel>
</rss>

