I’m having trouble with OAuth authentication when trying to create documents through Google Docs API in my Rails application. The request just hangs and doesn’t complete.
xml_payload = '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/docs/2007#spreadsheet" />
<atom:title>Employee Data</atom:title>
</atom:entry>'
base_string = 'POST&http://docs.google.com/feeds/documents/private/full&oauth_consumer_key=CONSUMER_KEY&oauth_nonce=abc123def456&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1234567890&oauth_version=1.0&xoauth_requestor_id=USER_EMAIL'
consumer_secret = 'SECRET_KEY'
signature = CGI.escape(Base64.encode64("#{OpenSSL::HMAC.digest('sha1', consumer_secret, base_string)}"))
request_headers = {
'Content-Type' => 'application/atom+xml',
'Authorization' => 'OAuth oauth_consumer_key="CONSUMER_KEY",oauth_nonce="abc123def456",oauth_signature=' + signature + ',oauth_signature_method="HMAC-SHA1",oauth_timestamp="1234567890",oauth_version="1.0"'
}
api_uri = URI.parse 'http://docs.google.com/feeds/documents/private/full?xoauth_requestor_id=USER_EMAIL'
http_client = Net::HTTP.new api_uri.host, api_uri.port
http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
http_client.use_ssl = true
response, result = http_client.post(api_uri.request_uri, xml_payload, request_headers)
Where:
- CONSUMER_KEY = OAuth consumer key
- USER_EMAIL = target user’s email address
- SECRET_KEY = OAuth consumer secret
Any ideas what might be causing this?