HTTPClient can't login to Google Voice

Discussion in 'Ruby' started by Mike Telis, Aug 3, 2010.

  1. Mike Telis

    Mike Telis Guest

    I'm trying to login to Google Voice using the following code:


    require 'httpclient'

    Google_Login = 'googlename'
    Google_Password = 'password'

    PRE_LOGIN_URL = "https://www.google.com/accounts/ServiceLogin"
    LOGIN_URL = "https://www.google.com/accounts/ServiceLoginAuth"
    VOICE_HOME_URL = "https://www.google.com/voice"

    clnt = HTTPClient.new:)agent_name => "Mozilla/5.0 (Macintosh; U; Intel
    Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2")
    #clnt.debug_dev = STDERR

    resp = clnt.get PRE_LOGIN_URL

    clnt.cookie_manager.cookies.each {|x| @galx=x.value if x.name == 'GALX'}
    # fetch GALX

    resp = clnt.post_content LOGIN_URL,
    :service => 'grandcentral',
    :continue => 'https://www.google.com/voice',
    :Email => Google_Login,
    :passwd => Google_Password,
    :GALX => @galx

    and post_content ends up redirecting to non-https URL (which is
    definitely wrong). BTW, I believe that post_content should change method
    to :get on redirect.

    Any ideas what might be wrong with the code (or library)?
    --
    Posted via http://www.ruby-forum.com/.
     
    Mike Telis, Aug 3, 2010
    #1
    1. Advertising

  2. Mike Telis

    Jason Watson Guest

    On 2010-08-03 18:26:16 +0100, Mike Telis said:

    > I'm trying to login to Google Voice using the following code:
    >
    >
    > require 'httpclient'
    >
    > Google_Login = 'googlename'
    > Google_Password = 'password'
    >
    > PRE_LOGIN_URL = "https://www.google.com/accounts/ServiceLogin"
    > LOGIN_URL = "https://www.google.com/accounts/ServiceLoginAuth"
    > VOICE_HOME_URL = "https://www.google.com/voice"
    >
    > clnt = HTTPClient.new:)agent_name => "Mozilla/5.0 (Macintosh; U; Intel
    > Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2")
    > #clnt.debug_dev = STDERR
    >
    > resp = clnt.get PRE_LOGIN_URL
    >
    > clnt.cookie_manager.cookies.each {|x| @galx=x.value if x.name == 'GALX'}
    > # fetch GALX
    >
    > resp = clnt.post_content LOGIN_URL,
    > :service => 'grandcentral',
    > :continue => 'https://www.google.com/voice',
    > :Email => Google_Login,
    > :passwd => Google_Password,
    > :GALX => @galx
    >
    > and post_content ends up redirecting to non-https URL (which is
    > definitely wrong). BTW, I believe that post_content should change method
    > to :get on redirect.
    >
    > Any ideas what might be wrong with the code (or library)?



    I could log in to Google with this:

    require 'net/https'

    def auth user_email, passwd, account_type, service
    http = Net::HTTP.new("www.google.com", 443)
    http.use_ssl = true

    path = "/accounts/ClientLogin"
    data =
    "accountType=#{account_type}&Email=#{user_email}&Passwd=#{passwd}&service=#{service}"


    headers = {'Content-Type' => 'application/x-www-form-urlencoded'}

    resp, data = http.post(path, data, headers)

    puts resp.code
    puts resp.body

    cl_string = data[/Auth=(.*)/,1]
    headers["Authorization"] = "GoogleLogin auth=#{cl_string}"

    end

    auth "email", "pass", "GOOGLE", "grandcentral"

    jbw
     
    Jason Watson, Aug 3, 2010
    #2
    1. Advertising

  3. Mike Telis

    Mike Telis Guest

    Jason W. wrote:

    > I could log in to Google with this:


    Guess it was long time ago, before Google added that GALX thing...

    > http.use_ssl = true

    http.verify_mode = OpenSSL::SSL::VERIFY_NONE # added this line

    I tried this code and it didn't work:

    403
    Error=BadAuthentication

    Any other ideas?
    --
    Posted via http://www.ruby-forum.com/.
     
    Mike Telis, Aug 3, 2010
    #3
  4. Mike Telis

    Jason Watson Guest

    [Note: parts of this message were removed to make it a legal post.]

    On 2010-08-03 20:16:04 +0100, Mike Telis said:

    > Jason W. wrote:
    >
    >> I could log in to Google with this:

    >
    > Guess it was long time ago, before Google added that GALX thing...
    >
    >> http.use_ssl = true

    > http.verify_mode = OpenSSL::SSL::VERIFY_NONE # added this line
    >
    > I tried this code and it didn't work:


    What does the code look like now? Added that line to mine and ir still works.

    > 403
    > Error=BadAuthentication
    >
    > Any other ideas?


    I've not used httpclient before or google's API much so I don't know
    about GALX. I've used HTTParty for this sort of stuff though.
     
    Jason Watson, Aug 3, 2010
    #4
  5. Mike Telis

    Mike Telis Guest

    > I've not used httpclient before or google's API much so I don't know
    > about GALX. I've used HTTParty for this sort of stuff though.


    Thanks for the tip! I've tried net/http, RestClient and HTTPClient and
    all failed in a similar manner. I think I'm doing something wrong and
    I'd rather find out what it is than try yet another library.
    --
    Posted via http://www.ruby-forum.com/.
     
    Mike Telis, Aug 3, 2010
    #5
  6. Mike Telis

    Jason Watson Guest

    On 2010-08-03 21:21:48 +0100, Mike Telis said:

    >>
    >> I've not used httpclient before or google's API much so I don't know
    >> about GALX. I've used HTTParty for this sort of stuff though.

    >
    > Thanks for the tip! I've tried net/http, RestClient and HTTPClient and
    > all failed in a similar manner. I think I'm doing something wrong and
    > I'd rather find out what it is than try yet another library.


    I don't think the API for this is even released offically? But there is
    lots of documented examples on Google's website for other API services,
    maybe they'll help.
     
    Jason Watson, Aug 3, 2010
    #6
  7. Mike Telis

    Guest

    On Tue, Aug 3, 2010 at 1:26 PM, Mike Telis <> wrote:
    > I'm trying to login to Google Voice using the following code:
    >...
    > PRE_LOGIN_URL =A0 =3D "https://www.google.com/accounts/ServiceLogin"
    > LOGIN_URL =A0 =A0 =A0 =3D "https://www.google.com/accounts/ServiceLoginAu=

    th"
    > VOICE_HOME_URL =A0=3D "https://www.google.com/voice"
    >...
    > resp =3D clnt.post_content =A0LOGIN_URL,
    > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:service =A0=3D> 'grandcentral',
    > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:continue =3D> 'https://www.google.com=

    /voice',
    > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:Email =A0 =A0=3D> Google_Login,
    > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:passwd =A0 =3D> Google_Password,
    > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:GALX =A0 =A0 =3D> @galx


    http://everydayscripting.blogspot.com/2009/10/python-fixes-to-google-login-=
    script.html

    login_params =3D urllib.urlencode( {
    'Email' : email,
    'Passwd' : password,
    'continue' : 'https://www.google.com/voice/account/signin',
    'GALX': galx_value
    })

    Slightly different parameters?

    > and post_content ends up redirecting to non-https URL (which is
    > definitely wrong). BTW, I believe that post_content should change method
    > to :get on redirect.


    I noticed that this redirect only happened when a valid username and
    password was entered. I hacked my copy of httpclient to not raise the
    exception so I could take a look at what was being returned:

    "If you've been redirected to this page from the sign-in box, we've
    detected an error with your cookie settings. Please follow the
    instructions for your browser listed below. After clearing your cache
    and cookies, try signing in again."
     
    , Aug 3, 2010
    #7
  8. Mike Telis

    Mike Telis Guest

    unknown wrote:
    > On Tue, Aug 3, 2010 at 1:26 PM, Mike Telis <> wrote:
    >> � � � � � � � � �:passwd � => Google_Password,
    >> � � � � � � � � �:GALX � � => @galx

    >
    > http://everydayscripting.blogspot.com/2009/10/python-fixes-to-google-login-script.html
    >
    > login_params = urllib.urlencode( {
    > 'Email' : email,
    > 'Passwd' : password,
    > 'continue' : 'https://www.google.com/voice/account/signin',
    > 'GALX': galx_value
    > })
    >
    > Slightly different parameters?


    Unfortunately, this doesn't work :-( I changed parameters as you
    suggested and got the same result. I've checked email and password many
    times, they are correct.
    --
    Posted via http://www.ruby-forum.com/.
     
    Mike Telis, Aug 4, 2010
    #8
  9. Mike Telis

    Mike Telis Guest

    Mike Telis, Aug 5, 2010
    #9
  10. Mike Telis

    Mike Telis Guest

    I'm redirected to:

    http://www.google.com/support/accounts/bin/answer.py?answer=32050&amp;hl=en&amp;ctx=ch_CheckCookie"

    and the CheckCookie part hints that HTTPClient is doing something wrong
    with the cookies.
    --
    Posted via http://www.ruby-forum.com/.
     
    Mike Telis, Aug 5, 2010
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sergey Muschin

    Voice over IP and .NET

    Sergey Muschin, Oct 20, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    590
    Adalert
    Jun 2, 2011
  2. Replies:
    4
    Views:
    1,230
    Juan T. Llibre
    Jan 27, 2007
  3. Replies:
    8
    Views:
    1,031
  4. Replies:
    0
    Views:
    598
  5. Rajesh B.
    Replies:
    0
    Views:
    229
    Rajesh B.
    Feb 16, 2011
Loading...

Share This Page