Last active
November 6, 2016 16:38
-
-
Save jlitven/922583d192f0b981ae8c40b94c1f7725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) # for sending requests | |
# Get the Spotify token header for API calls | |
# Returns: | |
# Header for GET requests | |
get_token_header = function(){ | |
clientID = 'your client id here' | |
secret = 'your secret id here' | |
response = POST( | |
'https://accounts.spotify.com/api/token', | |
accept_json(), | |
authenticate(clientID, secret), | |
body = list(grant_type = 'client_credentials'), | |
encode = 'form', | |
verbose() | |
) | |
mytoken = content(response)$access_token | |
HeaderValue = paste0('Bearer ', mytoken) | |
return(HeaderValue) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment