1

I'm trying to get data from Spotify by API. For example get audio features for a track (https://api.spotify.com/v1/audio-features/{id}), which needs authorization.

Example query is:

search_query <- "https://api.spotify.com/v1/audio-features/6pnwfWyaWjQiHCKTiZLItr"
fromJSON(search_query, flatten = TRUE)

before that, I try to authorize my scitpt by:

spotifyKey <- "xxxxxxxxxxxxxxxxxxxx"
spotifySecret <- "zzzzzzzzzzzzzzzzzzzzzz"
spotifyEndpoint <- oauth_endpoint(NULL, "https://accounts.spotify.com/authorize", "https://accounts.spotify.com/api/token")
spotifyApp <- oauth_app("spotify", spotifyKey, spotifySecret)
spotifyToken <- oauth2.0_token(spotifyEndpoint, spotifyApp)

Last line (spotifyToken <-...) opens browser, I can login into Spotify, but there is an error:

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error in curl::curl_fetch_memory(url, handle = handle) :
  Stream error in the HTTP/2 framing layer

So fromJSON() from the begining says Error 401. How to avoid this?

0 Answers0