nabeelamjad / poke-api

Poke API - A Ruby API gem for Pokémon GO.
MIT License
82 stars 22 forks source link

Issue with google login #10

Closed dphuang2 closed 8 years ago

dphuang2 commented 8 years ago

I keep getting this issue when logging in with google:

INFO > Poke::API::Client --: [+] Logging in user: xxx@gmail.com Poke::API::Errors::LoginFailure: Unable to login to GOOGLE => [undefined method split' for :"user-agent":Symbol @ /Users/xxx/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/net/http/header.rb:172:incapitalize']

To recreate: client = Poke::API::Client.new client.login("someone@gmail.com","password","google")

nabeelamjad commented 8 years ago

I'm not getting this

[2016-07-27T18:36:51+00:00]: INFO  > Poke::API::Client         --: [+] Logging in user: someone@gmail.com
Poke::API::Errors::LoginFailure: Unable to login to GOOGLE => [Unable to login to Google, could not find => Token in {"Error"=>"CaptchaRequired", "CaptchaToken"=>"1tupcUOKdhcoej6GdL24gipWp85XDrRLkyHn9YQCRH80DaYQGtZPmBAcdTanYa_KlEEFiiQUkVHJKpe-S3bP7J4-GVJAndtUD-dJm702SkU:SCH19wE15ZjcbKGz65JHXg", "CaptchaUrl"=>"Captcha?ctoken=1tupcUOKdhcoej6GdL24gipWp85XDrRLkyHn9YQCRH80DaYQGtZPmBAcdTanYa_KlEEFiiQUkVHJKpe-S3bP7J4-GVJAndtUD-dJm702SkU%3ASCH19wE15ZjcbKGz65JHXg", "Url"=>"https://accounts.google.com/ErrorMsg?Email=someone%40gmail.com&id=cr&service=ac2dm"} @ /home/ec2-user/.rvm/gems/ruby-2.3.1/gems/poke-api-0.0.3/lib/poke-api/auth/google.rb:43:in `perform_request']
        from /home/ec2-user/.rvm/gems/ruby-2.3.1/gems/poke-api-0.0.3/lib/poke-api/client.rb:24:in `rescue in login'
        from /home/ec2-user/.rvm/gems/ruby-2.3.1/gems/poke-api-0.0.3/lib/poke-api/client.rb:20:in `login'
        from (irb):3
        from /home/ec2-user/.rvm/rubies/ruby-2.3.1/bin/irb:11:in `<main>

Make sure you have the latest version of poke-api (0.0.3) and try updating your gems/ruby. I'm using Ruby 2.3.1.

nabeelamjad commented 8 years ago

So after investigating this is related to Ruby 2.2.4, you can view the offending line here (it is used by HTTParty which is used by gpsoauth-rb)

Here's what's going on for Ruby 2.2.4

def capitalize(name)
  name.split(/-/).map {|s| s.capitalize }.join('-')
end

capitalize(:'user-agent')

NoMethodError: undefined method `split' for :"user-agent":Symbol

The mistake has been corrected for Ruby 2.3.1 (and possibly earlier versions) at least by converting it into a String first (this ensures that a Symbol does not return an error).

def capitalize(name)
  name.to_s.split(/-/).map {|s| s.capitalize }.join('-')
end

If gpsoauth-rb changes this line to {'User-Agent' => USER_AGENT, 'Cookie' => cookie} then it should work fine.

nabeelamjad commented 8 years ago

Tagging @xssc

xssc commented 8 years ago

@nabeelamjad thanks for investigating the issue, I made the change and pushed it as v0.1.2 so should just need to change spec.add_runtime_dependency 'gpsoauth-rb', '0.1.1' to '0.1.2'

nabeelamjad commented 8 years ago

11 will resolve this issue for the master branch, I will update the tag later.

dphuang2 commented 8 years ago

@nabeelamjad Thanks for the support~!

nabeelamjad commented 8 years ago

@dphuang2 The new tag, 0.0.4, has been pushed, I'll close this off now.