简体   繁体   中英

Google Buzz API OAuth Problem - Using Zend_OAuth (PHP)

I have successfully gotten an access_token, so it's not a problem with the 3-legged process.

The problem starts when I try to add a new post/activity using the Buzz API...

Here is my request:

POST /buzz/v1/activities/@me/@self?alt=json HTTP/1.1 
Host: www.googleapis.com 
Connection: close 
Accept-encoding: gzip, deflate 
User-Agent: Zend_Http_Client 
Content-Type: application/json 
Authorization: OAuth 
realm="",oauth_consumer_key="example.com",oauth_nonce="ce29b04ce6648fbb92efc8f 08c1c0091",oauth_signature_method="HMAC- 
SHA1",oauth_timestamp="1277934794",oauth_version="1.0",oauth_token="1%2FcBz o5ckGvCAm3wLWh1SDH3xQNoW-- 
yek1NVfUa1Qqns",oauth_signature="CUezSiMbvxyN1BTeb3uROlIx8gA%3D" 
Content-Length: 86 
{"data":{"object":{"type":"note","content":"posting on Buzz"}}} 

Here is the response:

{"error":{"errors":[{"message":"Unknown authorization header","locationType":"header","location":"Authorization"}],"code":401,"message":"Unknown authorization header"}}

And here is my base string (the string that the signature gets generated from):

POST&https%3A%2F%2Fwww.googleapis.com%2Fbuzz%2Fv1%2Factivities%2F%40me 
%2F%40self&oauth_consumer_key%3Dexample.com%26oauth_nonce 
%3D50acc6b7ac48304ae9301134d6988cdb%26oauth_signature_method%3DHMAC- 
SHA1%26oauth_timestamp%3D1278065599%26oauth_token 
%3D1%252FcBzo5ckGvCAm3wLWh1SDH3xQNoW--yek1NVfUa1Qqns%26oauth_version 
%3D1.0 

I've even tried this other base string (with the alt=json added in):

POST&https%3A%2F%2Fwww.googleapis.com%2Fbuzz%2Fv1%2Factivities%2F%40me
  %2F%40self%3Falt%3Djson&oauth_consumer_key%3Dexample.com%26oauth_nonce
  %3Dee8704244623bbcc860bf77bfcadeacc%26oauth_signature_method%3DHMAC-
  SHA1%26oauth_timestamp%3D1278069221%26oauth_token
  %3D1%252FcBzo5ckGvCAm3wLWh1SDH3xQNoW--yek1NVfUa1Qqns%26oauth_version
  %3D1.0

I have tried pretty much everything to get this working - not sure why it always says 'Unknown authorization header'... the header looks fine when compared to other ones that work.

Any ideas?

which endpoint did you use to authorize request token?

developer's guide :

Important: Part of the OAuth process requires that you direct the user to the Google Authorization service to approve access for your application. Google Buzz requires that you use a different Authorization service endpoint, located at https://www.google.com/buzz/api/auth/OAuthAuthorizeToken.com/buzz/api/auth/OAuthAuthorizeToken .

You should use GET or POST method (depending what request you use). By default Zend uses header-method.

$client->setMethod(Zend_Http_Client::GET);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM