0
votes

Am trying to create a doc (very very basic) using 2-legged OAuth (https://developers.google.com/accounts/docs/OAuth) - in my web server.

Here's the code:

!* Clicked: Run Btn *

ThisWebClient.SetAllHeadersDefault()
ThisWebClient.HeaderOnly = 0
ThisWebClient.Host = 'http://docs.google.com'
ThisWebClient.ContentType = 'application/atom+xml'
ThisWebClient.Authorization = 'OAuth oauth_version="1.0", '&|
  'oauth_nonce="'&today()&clock()&'", '&|
  'oauth_timestamp="'&clock()&'", '&|
  'oauth_consumer_key="..google user content string..", '&|
  'oauth_signature_method="HMAC-SHA1", '&|
  'oauth_signature="..signature string.."'
ThisWebClient.Post('https://docs.google.com/feeds/documents/private/full?xoauth_requestor_id=stu.a%40sandersnoonan.com',|
  '<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#document" /><atom:title>SNIPS Stuff</atom:title></atom:entry>')

(screenshot taken, initially posted)

enter image description here

I'm currently getting a 401 error, Unknown authorization header.

-- This is my first go with OAuth and using Google APIs for development, so I might have missed something VERY simple.

Any ideas?

1
Please next time include your code as text in a code block and not as image. - Jan Gerlinger
Done. Included code. Thanks for the heads up. - Stu Andrews

1 Answers

1
votes

The oauth_signature can't be hardcoded into your code. It is for each request calculated using HMAC-SHA1 and dependent on your timestamp, nonce, etc.

Google also has documentation for the signing step.