This repo contains a set of PowerShell Azure Functions which export Spotify user data (playlists and user library) to .csv
files in Azure Blob Storage.
The SpotifyExporter application requires the creation of 3 secrets in order to configure the Azure Function to export your Spotify library:
- Spotify Developer Application Client ID
- Spotify Developer Application Client Secret
- Spotify User OAuth 2 Refresh Token
Users must obtain a Client ID and Client Secret by registering a Spotify App, as well as an OAuth 2 Refresh token using the Authorization Code Flow.
If you don't know what to use as a Redirect URI, http://localhost:8080/spotifyexporter is a good default.
Once you have created your app, use the Client ID
, Client Secret
, and Redirect URI
as the parameters for Get-SpotifyRefreshToken.ps1 in the following section.
- Download this repo to your local machine by clicking the Green Code button and choosing Download ZIP.
- Unzip
SpotifyExporter.zip
to any folder on your computer. - Install or open PowerShell.
- If you have a Windows computer, launch it by pressing Win + R and typing powershell.
- If you have a MacOS computer, install PowerShell. Launch PowerShell by pressing Cmd + Space and typing PowerShell.
- Navigate to the folder where you extracted
SpotifyExporter.zip
using thecd
command.- Example:
cd ./Downloads/SpotifyExporter
.
- Example:
- Execute the
Get-SpotifyRefreshToken.ps1
script using the values obtained from your Spotify Developer Application.- Example:
./auth/Get-SpotifyRefreshToken.ps1 -ClientId 'c0b51074872b4822b30fe887ce857b47' -ClientSecret '397c93a60153496abbc1458ac1978655' -RedirectUri 'http://localhost:8080/spotifyexporter'
The users's default web browser will open and request them to sign into Spotify, granting read access to their profile for the Spotify Developer Application they registered.
Users can also execute
Get-SpotifyRefreshToken.ps1
with the-ManualAuth
switch parameter to prevent the web browser automatically opening. This method will prompt the user to paste a URL into their web browser manually, and then paste the redirect URL into the PowerShell console.
After completing the login process, the user will receive an OAuth 2 Refresh Token in their PowerShell console. This Refresh Token should be treated as a secret and stored in a safe place. It will be required in the next step: Azure Resource Manager Custom Deployment.
This application can be deployed directly to Azure as a PowerShell Function App.
Provide the Spotify Client Id, Spotify Client Secret, and Spotify Refresh Token obtained above as the required parameters for the Azure Resource Manager Custom Deployment.
- To enable diagnostic logging to an Azure Log Analytics Workspace, set the
Logs Enabled
deployment parameter to true.- Incurs additional cost for log ingestion and storage.
- To enable data export to a free-tier Azure Cosmos DB NoSQL Database, set the
Cosmos Enabled
deployment parameter to true. - To disable data export to Azure Storage as
.csv
files, set theStorage Export Enabled
deployment parameter to false.
If you run into any issues with this repo, please open an issue or pull request.