Based on: https://gist.github.com/marco79cgn/79a6a265d978dc22cc2a12058b24e02b
Widget for iOS 14 showing your most listened to tracks within the past four weeks.
Instructions from Authorization Code Flow
1.) Go to Spotify Developer API and create a new Application
2.) Hit "Edit Settings" and add https://spotify.com as Redirect URI
3.) Store Client ID and Client Secret in an Editor
4.) Open a new incognito browser tab: https://accounts.spotify.com/authorize?client_id=YOURCLIENTID&response_type=code&redirect_uri=https%3A%2F%2Fspotify.com&scope=user-top-read (Make sure to replace YOURCLIENTID)
5.) Click "Accept"
6.) You will be redirected to something like https://www.spotify.com/de/?code=AQD4q4v6Klt9ZW5VtTbnbHAWDLKK8y1t6Ammov.....
7.) Store this code once again in an Editor
8.) (Base64 Encode)[https://www.base64encode.org/] "<client_id>:<client_secret>"
9.) curl -H "Authorization: Basic ZjM...zE=" -d grant_type=authorization_code -d code=MQCbtKe...44KN -d redirect_uri=https%3A%2F%2Fspotify.com https://accounts.spotify.com/api/token > spotify_access_token.json
, where ZjM...zE= is the Base64 encoded string from Step 8 and MQCbtKe...44KN the code from step 7
10.) You'll receive an access and a refresh token
11.) Create a new File called spotify-credentials.json using all your collected data:
{
"clientSecret": "YOURCLIENTSECRET",
"clientId": "YOURCLIENTID",
"accessToken": "ACCESS TOKEN FROM STEP 10",
"refreshToken": "REFRESH TOKEN FROM STEP 10"
}
12.) Store this JSON File in your iCloud Drive under Scriptable/spotify-credentials.json
- Make sure to have iOS 14 installed
- Download Scriptable App
- Copy the code from this repo into the clipboard
- Paste it in a new Scriptable script
- Create a new Scriptable widget, choose a layout (last one recommended)
- Under Parameters select how many tracks will be shown (max is 10) and select the period ([1-10],["short", "medium", "long"])