Generation of SPOTIFY_OAUTH_TOKEN from CLIENT_ID and CLIENT_SECRET

This commit is contained in:
Nicolás Alonso 2017-10-08 22:37:02 -03:00
commit ac3e66cfdd
2 changed files with 7 additions and 0 deletions

View file

@ -355,6 +355,8 @@ function spotify() {
len=${#array[@]};
SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search"
SPOTIFY_PLAY_URI="";
SPOTIFY_CALL_TOKEN=$(python2 -c "import base64; print base64.standard_b64encode('$SPOTIFY_CLIENT_ID:$SPOTIFY_CLIENT_SECRET')")
SPOTIFY_OAUTH_TOKEN=$(curl -s -X "POST" -H "Authorization: Basic $SPOTIFY_CALL_TOKEN" -d grant_type=client_credentials https://accounts.spotify.com/api/token | python2 -c "import sys, json; print json.load(sys.stdin)['access_token']")
SPOTIFY_AUTH="Authorization: Bearer $SPOTIFY_OAUTH_TOKEN"
searchAndPlay() {

View file

@ -57,6 +57,11 @@ source $ZSH/oh-my-zsh.sh
# User configuration
# Uncomment the following lines if you want to enable spotify search.
# Spotify data can be found creating an app in https://developer.spotify.com/my-applications
# SPOTIFY_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# SPOTIFY_CLIENT_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment