官术网_书友最值得收藏!

Creating a configuration file

Let's go ahead and create a file called config.yaml in the musicterminal directory with the following contents:

client_id: '<your client ID>'
client_secret: '<your client secret>'
access_token_url: 'https://accounts.spotify.com/api/token'
auth_url: 'http://accounts.spotify.com/authorize'
api_version: 'v1'
api_url: 'https://api.spotify.com'
auth_method: 'AUTHORIZATION_CODE'

client_id and client_secret are the keys that were created for us when we created the Spotify application. These keys will be used to get an access token that we will have to acquire every time we need to send a new request to Spotify's REST API. Just replace the <your client ID> and <your client secret> with your own keys.

Keep in mind that these keys have to be kept in a safe place. Don't share the keys with anyone and if you are having your project on sites like GitHub, make sure that you are not committing this configuration file with your secret keys. What I usually do is add the config file to my .gitignore file so it won't be source-controlled; otherwise, you can always commit the file as I did by presenting it with placeholders instead of the actual keys. That way, it will be easy to remember where you need to add the keys.

After the client_id and client_secret keys, we have the access_token_url. This is the URL to the API endpoint that we have to perform requests on in order to get the access token.

 auth_url is the endpoint of Spotify's Account Service; we will use it when we need to acquire or refresh an authorization token.

The api_version, as the name says, specifies Spotify's REST API version. This is appended to the URL when performing requests.

Lastly, we have the api_url, which is the base URL for Spotify's REST API endpoints.

主站蜘蛛池模板: 屯门区| 梨树县| 蕉岭县| 信宜市| 衡阳县| 共和县| 德庆县| 乐平市| 上思县| 青铜峡市| 潜江市| 台江县| 兴宁市| 太康县| 沙田区| 区。| 邢台市| 金川县| 观塘区| 尼玛县| 马公市| 萍乡市| 贡觉县| 佛学| 太保市| 灵山县| 延寿县| 门头沟区| 内黄县| 中卫市| 衡水市| 蚌埠市| 灵山县| 富锦市| 盐源县| 鄂尔多斯市| 井冈山市| 双柏县| 吴旗县| 大港区| 鄂托克旗|