# Net/http for Googles Authentication api

**URL:** <https://www.ruby-forum.com/t/net-http-for-googles-authentication-api/107936>\
**Category:** Ruby\
**Created:** [June 27, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/net-http-for-googles-authentication-api/107936 "2007-06-27T18:37:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [June 27, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/net-http-for-googles-authentication-api/107936/1 "2007-06-27T18:37:56Z")

</div>

```
def process_token(token)
  url =

```

URI.parse(‘[http://www.google.com/account/AuthSubSessionToken/](http://www.google.com/account/AuthSubSessionToken/)’)

```
  request = Net::HTTP::Get.new(url.path)
  request['Content-Type'] = "text/html; charset=utf-8"
  request['User-Agent'] = "Ruby client"
  request['Authorization'] = "AuthSub token='#{token}'"
  res = Net::HTTP.start(url.host, 80) do |sess|
    sess.request(request)
  end
end

```

That is the code I’m using to send a request to  
[http://www.google.com/account/AuthSubSessionToken/](http://www.google.com/account/AuthSubSessionToken/) with a special header  
attribute (Authorization) containing a token provided by Google. The  
code above results in a 404 exception, I don’t think it’s sending the  
correct request.

Any suggestions as to what I did wrong or how I can view the entire  
request sent so I at least have an idea of whats wrong?

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [June 27, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/net-http-for-googles-authentication-api/107936/2 "2007-06-27T19:38:34Z")

</div>

Joe S. wrote:

> ```
> sess.request(request)
> 
> ```
> 
> request sent so I at least have an idea of whats wrong?

A 404 not found is not something that a server usually spits out when  
you have merely given it the wrong information. Error, Access Denied,  
Authentication Failed, something, but not a 404. So I strongly suspect  
your URL is wrong. Try https? (though that would mean using Net::HTTPS  
instead of Net::HTTP). One strategy would be to find something that  
successfully connects to Google by this method (if you have a working  
example in another language, or even a binary file), you should run that  
and sniff your own packets to see exactly what is being sent.  
“livehttpheaders” is a Firefox extension that I use for this sort of  
thing, if there is any way for you to use a web browser to log in to  
this google authentication thing.

Good luck,  
Dan
