diff --git a/lib/rspotify/user.rb b/lib/rspotify/user.rb index 7f4332e9..0f4ef779 100644 --- a/lib/rspotify/user.rb +++ b/lib/rspotify/user.rb @@ -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