The first necessary conditions for obtaining the credentials for using the Spotify Web API is having a valid account for the application.
As a next step, we need to register an app in Spotify for Developers. As you already should have a valid user and password for Spotify, you should log in with that Spotify Account and then click in the create an app button. For a valid app, only a name and a description is necessary (as well as accepting Spotify's developer terms). The purpose of creating this app is obtaining two central things: the client ID and the client secret.
These client ID and the client secret are the credentials needed to obtain the OAth 2.0 token, in order to interact with the API. Again, in the dashboard tab, we find the client ID at the left of the screen; below the name and the description. In order to see the secret, we have to click in show client secret. Finally, the token is obtained via a POST request to the API itself (detailed in the FinalRMD).
The final step is to create two .txt documents outside the folder of the repository, named:
- client_id.txt (Containing only the Client ID).
- client_secret.txt (Contaning only the Client secret). They should only include the respective information for each one, and nothing else.
Note: for an easier and quicker access to the API, place these into an easy directory, as you will later need to link them to the .Rmd.
Once this is done, just paste the directories in the chunks in lines 51 and 55, and the 'Spotify scraper.Rmd' will be ready to run, so that you can easily scrape Spotify's information.
Thus, the process can be summarised in:
- Creating a Spotify account.
- Loging in in Registering an app in Spotify for Developers.
- Obtaining the Client ID and Client secret and storing them in two separate .txt files, in the specified format.
- Link these two .txt to the .Rmd document, sepcifying where they're located.
- Run the code.