speric/kindle-highlights

Unable to sign in

rmangino opened this issue · 6 comments

I'm using v1.0.2 of this gem on macOS 10.12.3. My ruby version is: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15].

My test code:

require 'kindle_highlights'

kindle = KindleHighlights::Client.new(email_address: "myemail@address.com",
                                      password: "password")
puts kindle.books

I know my email address and password are correct because I'm copying and pasting the exact values I use when logging into amazon.com manually.

I'm receiving this error:

$ ruby kindle.rb
/Users/me/.rvm/gems/ruby-2.3.0/gems/kindle-highlights-1.0.2/lib/kindle_highlights/client.rb:55:in `conditionally_sign_in_to_amazon': Unable to sign in, received error: 'Enter a valid email or mobile number' (KindleHighlights::Client::AuthenticationError)
from /Users/me/.rvm/gems/ruby-2.3.0/gems/kindle-highlights-1.0.2/lib/kindle_highlights/client.rb:63:in `load_books_from_kindle_account'
from /Users/me/.rvm/gems/ruby-2.3.0/gems/kindle-highlights-1.0.2/lib/kindle_highlights/client.rb:16:in `books'
from kindle.rb:6:in `<main>'

I've tried passing different values for mechanize_options: { user_agent_alias: 'Mac Safari' } but I still recieve the same error.

Have you seen this issue before? TIA

c01o commented

Another one here.

gem: 1.0.2
ruby: 2.4.0p0 (2016-12-24 revision 57163) [x86_64-linux]
OS: Ubuntu 16.04 LTS

 /usr/local/bundle/gems/mechanize-2.7.5/lib/mechanize.rb:372:in `click': undefined method `[]' for nil:NilClass (NoMethodError)
 	from /usr/local/bundle/gems/kindle-highlights-1.0.2/lib/kindle_highlights/client.rb:66:in `load_books_from_kindle_account'
 	from /usr/local/bundle/gems/kindle-highlights-1.0.2/lib/kindle_highlights/client.rb:16:in `books'
 	from /kindle/scrape.rb:57:in `<main>'
 exited with code 1

It looks login problem, so I inspected the signin_page in client.rb:

    def conditionally_sign_in_to_amazon
      retries ||= 0

      if @kindle_logged_in_page.nil?
        signin_page            = mechanize_agent.get(KINDLE_LOGIN_PAGE)
        p signin_page
        signin_form            = signin_page.form(SIGNIN_FORM_IDENTIFIER)
        signin_form.email      = email_address
        signin_form.password   = password
        p signin_page
        post_signin_page       = mechanize_agent.submit(signin_form)
        p signin_page

      ...

and found that login failed although the form looks correctly got completed(email, password).

Try changing UserAgent to the same one of my browser made no effect.
mechanize_agent.user_agent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0"

same issue found on stackoverflow: Using Mechanize to log into https://kindle.amazon.com/login

I've experienced some sign-in related issues, but they are tough to debug. Are you still having issues here?

It appears that Amazon has changed their Kindle Notes/Highlights site around, a lot. Since this gem assumes a certain structure as it crawls the Kindle site, it broke.

I am working on some fixes. Stay tuned!

@rmangino @c01o I recommend upgrading to v2.0.0. of this gem. The Kindle page structure changed significantly, and it broke older versions.

@speric I'm on v2.0.1 and experiencing sign in issues. I don't get any errors, but it returns empty for my books array, even though I have confirmed that there are indeed books there. Any suggestions ?

@rkartzman I am facing a similar issue. Were u able to resolve this?