谷歌嗡嗡声API - 无法解决错误:"Required Parameter Missing - grant_type"



我正在尝试用python制作一个桌面应用程序,以便向Google Buzz发布消息。我无法用access_token交换代码(我要求用户在授权应用程序后从浏览器复制粘贴的代码)。

我正在以以下方式向www.google.com4/accounts/o8/oauth2/token进行POST:

send: 'POST /accounts/o8/oauth2/token HTTP/1.1rnHost: www.google.comrnAccept-Encoding: identityrnContent-Length: 194rnrnclient_id=XXXXXXX.apps.googleusercontent.com&client_secret=XXXXXXXXXXXXXX&code=4/JFxWkTynH63BruP_dLqtJTV0O_oc&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob'
reply: 'HTTP/1.1 400 Required parameter is missing: grant_typern'
header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate
header: Pragma: no-cache
header: Expires: Fri, 01 Jan 1990 00:00:00 GMT
header: Date: Mon, 30 May 2011 09:04:36 GMT
header: Content-Type: text/html; charset=UTF-8
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-XSS-Protection: 1; mode=block
header: Server: GSE
header: Transfer-Encoding: chunked
400 Required parameter is missing: grant_type
<HTML>
<HEAD>
<TITLE>Required parameter is missing: grant_type</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Required parameter is missing: grant_type</H1>
<H2>Error 400</H2>
</BODY>
</HTML>

更具体地说,我以这种方式发送参数(复制、粘贴、从上面格式化):

POST /accounts/o8/oauth2/token HTTP/1.1rn
Host: www.google.comrn
Accept-Encoding: identityrn
Content-Length: 194rn
rn
client_id=XXXXXXX.apps.googleusercontent.com&
client_secret=XXXXXXXXXXXXXX&
code=4/JFxWkTynH63BruP_dLqtJTV0O_oc&
grant_type=authorization_code&
redirect_uri=urn:ietf:wg:oauth:2.0:oob

有什么想法/建议/建议吗?我应该如何修复此错误?我哪里错了吗?

谢谢你的时间和耐心。

致问候,

Srivatsan Iyer

[回答我的问题,希望它能帮助未来的读者]

我设法解决了我的问题。我使用Python的HTTPSConnection对上述数据进行了POST。GAE可能不太好用。我用了google.appengine.api.urlfetch,效果很好!:-)

相关内容

最新更新