guilhermesad / rspotify

A ruby wrapper for the Spotify Web API
MIT License
717 stars 290 forks source link

Auth arguments error - wrong number of arguments (given 2, expected 1) #255

Closed aspleenic closed 2 years ago

aspleenic commented 2 years ago

Trying to grab the top 5 tracks of an artist in a simple Sinatra app, but I get a wrong number of arguments regardless of the number of arguments given

require 'rubygems'
require 'bundler'
Bundler.setup

require 'sinatra'
require 'json'
require 'rest-client'
require 'rspotify'
require 'open-uri'
require 'nokogiri'
require 'rspotify/oauth'

get '/' do

  "Top 5 Tunes by The National on Spotify"

  RSpotify.authenticate('12345678abcdef', '987654321xyz')
  artist = RSpotify::Artist.find('2cCUtGK9sDU2EoElnk0GNB')
  tracks = artist.top-tracks.limit(5)

end

Error received: 2022-09-20 10:07:16 - ArgumentError - wrong number of arguments (given 2, expected 1): /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:in initialize' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:innew' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:in parse' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rspotify-2.11.1/lib/rspotify/connection.rb:32:inauthenticate' national.rb:19:in block in <main>' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in block in compile!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:inblock (3 levels) in route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1042:in route_eval' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:inblock (2 levels) in route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1071:in block in process_route' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:incatch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in process_route' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1021:inblock in route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in each' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:inroute!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1140:in block in dispatch!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:inblock in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in catch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:ininvoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1135:in dispatch!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:inblock in call!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in block in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:incatch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:incall!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:938:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/xss_header.rb:18:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/path_traversal.rb:16:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/json_csrf.rb:26:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/frame_options.rb:31:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/logger.rb:17:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/common_logger.rb:38:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:255:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:248:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/head.rb:12:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/method_override.rb:24:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/show_exceptions.rb:22:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:218:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1993:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in block in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1769:insynchronize' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/configuration.rb:252:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/request.rb:77:in block in handle_request' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:340:inwith_force_shutdown' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/request.rb:76:in handle_request' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/server.rb:441:inprocess_client' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:147:in `block in spawn_thread'

aspleenic commented 2 years ago

If i change to only pass the client secret, it says Argument error - wrong number of arguments (given 1, expected 2)

aspleenic commented 2 years ago

Issue was with outdated gems - closing this issue