Skip to content

Commit

Permalink
Merge pull request #262 from shaicoleman/playlist-add-tracks-token-fa…
Browse files Browse the repository at this point in the history
…llback

Fix for playlist.add_tracks! if no credentials for the playlist owner exist
  • Loading branch information
guilhermesad authored May 6, 2024
2 parents 0a95a52 + afdad1d commit 3f34a12
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rspotify/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ def self.extract_custom_headers(params)
private_class_method :extract_custom_headers

def self.oauth_header(user_id)
token = @@users_credentials.dig(user_id, 'token')
# Fallback for playlist.add_tracks! if no credentials for the playlist owner exist
token ||= @@users_credentials.values.dig(0, 'token')
{
'Authorization' => "Bearer #{@@users_credentials[user_id]['token']}",
'Authorization' => "Bearer #{token}",
'Content-Type' => 'application/json'
}
end
Expand Down

0 comments on commit 3f34a12

Please sign in to comment.