Closed shaicoleman closed 6 months ago
Calling add_tracks! causes the following exception:
add_tracks!
/home/shai/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/rspotify-2.12.1/lib/rspotify/user.rb:65:in `oauth_header': undefined method `[]' for nil (NoMethodError) 'Authorization' => "Bearer #{@@users_credentials[user_id]['token']}", ^^^^^^^^^ from /home/shai/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/rspotify-2.12.1/lib/rspotify/user.rb:73:in `oauth_send' from /home/shai/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/rspotify-2.12.1/lib/rspotify/user.rb:87:in `block (2 levels) in <class:User>' from /home/shai/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/rspotify-2.12.1/lib/rspotify/playlist.rb:165:in `add_tracks!'
This is because the add_tracks! tries to use the credentials of the playlist owner, instead of the current user's credentials. https://github.com/guilhermesad/rspotify/blob/0a95a52e1b2bbfbed65ff4b8cffee12beec74623/lib/rspotify/playlist.rb#L165
If the credentials for the users are not found, it will fall back to the first token.
Properly fixing it requires a breaking change, as you need to pass the user to the playlist, but this will fix it for most cases.
Looks good, thanks!
Calling
add_tracks!
causes the following exception:This is because the
add_tracks!
tries to use the credentials of the playlist owner, instead of the current user's credentials. https://github.com/guilhermesad/rspotify/blob/0a95a52e1b2bbfbed65ff4b8cffee12beec74623/lib/rspotify/playlist.rb#L165If the credentials for the users are not found, it will fall back to the first token.
Properly fixing it requires a breaking change, as you need to pass the user to the playlist, but this will fix it for most cases.