Spotify API

Developer Dashboard'dan uygulama olusturup buradan client id, client secret'i almalisiniz. Ayrica redirect uri'i da dashboard uzerinden ayarlayabilirsiniz. Bu ornekte http://localhost:8000/callback seklinde ayarlanmistir.

CODE'u AL

REQUEST

https://accounts.spotify.com/authorize?client_id=${CLIENTID}&response_type=code&redirect_uri=http://localhost:8000/callback&scope=scopes

RESPONSE

http://localhost:8000/callback?code=${CODE}

GET REFRESH'I AL

REQUEST

curl -H "Authorization: Basic ${base64 encoded client_id:client_secret>}" -d grant_type=authorization_code -d code=**CODE** -d redirect_uri=http://localhost:8000/callback https://accounts.spotify.com/api/token

RESPONSE

{ "access_token":"XXXXXX", "token_type": "Bearer", "expires_in": 3600, "refresh_token": ${REFRESH_TOKEN}, "scope": "user-read-currently-playing" }

Note:: Access token 1 saat icinde expire oluyor. Bu nedenle refresh tokenla expire oldugu zaman yenilemeniz gerekmektedir.

GET ACCESS_TOKEN

curl -H "Authorization: Basic ${base64 encoded client_id:client_secret>}" -d grant_type=refresh_token -d refresh_token=${REFRESH_TOKEN} https://accounts.spotify.com/api/token

NextJS ile bir ornek yaptigim video ektedir. Ayrica bir ornekte kendi sitemde mevcut.

Faydali Linkler

Spotify API Dokumantasyonu: https://developer.spotify.com/documentation/web-api/reference/#/

Leave A Comment!
There is no comment yet! Be first!