Site Tools


linux:ubuntu:spotify

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:ubuntu:spotify [2020/10/25 11:47] lunetikklinux:ubuntu:spotify [2023/01/18 16:10] (current) lunetikk
Line 1: Line 1:
 ====== Spotify ====== ====== Spotify ======
- 
-Work in progress... 
  
 [[https://developer.spotify.com/documentation/web-api/|Web API]]\\ [[https://developer.spotify.com/documentation/web-api/|Web API]]\\
-[[https://developer.spotify.com/console/|Console]]+[[https://developer.spotify.com/console/|Console]]\\ 
 +[[https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow|Authorization Guide]]\\ 
 + 
 +===== Register an App ===== 
 + 
 +[[https://developer.spotify.com/documentation/general/guides/authorization/app-settings/|Register App]] 
 + 
 +===== Get your Secrets ===== 
 + 
 +Get your ClientID, ClientSecret and CallbackURL from the registered App 
 + 
 +Create an Authcode, replace <YOURCLIENTID> and <YOURCALLBACKURL> with yours, you also might need to change the scope if you want to gather more info than just your current music. After opening the URL in your browser you will be redirected to an URL with your Code. 
 + 
 +<code> 
 +https://accounts.spotify.com/authorize?client_id=<YOURCLIENTID>&response_type=code&redirect_uri=http%3A%2F%2F<YOURCALLBACKURL>%2Fcallback%2F&scope=user-read-currently-playing 
 + 
 +Example:  
 +https://accounts.spotify.com/authorize?client_id=123abcidontcare&response_type=code&redirect_uri=http%3A%2F%2Flocalhost:3000%2Fcallback%2F&scope=user-read-currently-playing 
 + 
 +http://localhost:3000/callback/?code=AQCPtOSCKsPt..........YIcyfimgKFeejPg 
 +</code> 
 + 
 +Now decode your ClientID and ClientSecret with Base64 (online or via CLI) 
 + 
 +<code> 
 +echo "<YOURCLIENTID>:<YOURCLIENTSECRET>" | base64 
 + 
 +Example: 
 +echo "blabla:thisissecret" | base64 
 +TH1S1SS0D3C0D3DTH1S1SS0D3C0D3DTH1S1SS0D3C0D3DTH1S1SS0D3C0D3D 
 +</code> 
 + 
 +Now get your AccessToken and RefreshToken via CLI 
 + 
 +<code> 
 +curl -H "Authorization: Basic <YOURBASE64CODE>" -d grant_type="authorization_code" -d code="<YOURAUTHCODE>" -d redirect_uri="http%3A%2F%2F<YOURCALLBACKURL>%2Fcallback%2F" https://accounts.spotify.com/api/token 
 + 
 +Example: 
 +curl -H "Authorization: Basic TH1S1SS0D3C0D3DTH1S1SS0D3C0D3DTH1S1SS0D3C0D3DTH1S1SS0D3C0D3D" -d grant_type="authorization_code" -d code="AQCPtOSCKsPt..........YIcyfimgKFeejPg" -d redirect_uri="http%3A%2F%2Flocalhost:3000%2Fcallback%2F" https://accounts.spotify.com/api/token 
 + 
 +{"access_token":"BQCMW.........z8gNg","token_type":"Bearer","expires_in":3600,"refresh_token":"AQDn.........cXK_gU","scope":"user-read-currently-playing"
 +</code> 
 + 
 +===== Renew your AccessToken ===== 
 + 
 +If your AccessToken is expired, renew it with your RefreshToken 
 + 
 +<code> 
 +curl -H "Authorization: Basic <YOURBASE64CODE>" -d grant_type="refresh_token" -d refresh_token="<YOURREFRESHTOKEN>" -d redirect_uri="http%3A%2F%2F<YOURCALLBACKURL>%2Fcallback%2F" https://accounts.spotify.com/api/token 
 + 
 +Example: 
 +curl -H "Authorization: Basic TH1S1SS0D3C0D3DTH1S1SS0D3C0D3DTH1S1SS0D3C0D3DTH1S1SS0D3C0D3D" -d grant_type="refresh_token" -d refresh_token="AQDn.........cXK_gU" -d redirect_uri="http%3A%2F%2Flocalhost:3000%2Fcallback%2F" https://accounts.spotify.com/api/token 
 + 
 +{"access_token":"BQC2e.........LDSA","token_type":"Bearer","expires_in":3600,"scope":"user-read-currently-playing"
 +</code> 
 + 
 +===== Get your current music ===== 
 + 
 +You can get your music via the following CURL to check your AccessToken 
 + 
 +<code> 
 +curl -X "GET" "https://api.spotify.com/v1/me/player/currently-playing" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer <YOURACCESSTOKEN>" 
 + 
 +Example: 
 +curl -X "GET" "https://api.spotify.com/v1/me/player/currently-playing" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BQCMW.........z8gNg" 
 +</code> 
 + 
 + 
linux/ubuntu/spotify.1603622859.txt.gz · Last modified: 2020/10/25 11:47 by lunetikk