我使用Python 实现了对Google App Engine 的实验性OAuth支持,并让它在本地工作,但是当我部署到appspot时,端点投入了400.
例如,url http(s)://my-app.appspot.com/_ah/OAuthGetRequestToken返回400,但本地该url模式的行为与预期一致.
我尝试了http和https,并假设appspot处理ssl证书.
UPDATE
我一直在使用OAuth Playground来测试我的代码.尽管文档,似乎注册您的应用程序的需要.转到这里了解如何登记的说明.根据注册过程中的文档,在App Engine上运行时不需要证书.Playground正在显示有关错误的更多详细信息 - "签名无效".如果我理解正确,签名是从签名基本字符串生成的.在这种情况下,我使用基本字符串7DYB6MJ2s-IQcd7VJYJUmcct.
GET /accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fmail.google.com%2Fmail%2Ffeed%2Fatom HTTP/1.1 Host: www.google.com Accept: */* Authorization: OAuth oauth_version="1.0", oauth_nonce="168cfd60a93a46caa38dddfdcedd9de9", oauth_timestamp="1305315895", oauth_consumer_key="xxxxxxx.appspot.com", oauth_callback="http%3A%2F%2Fgooglecodesamples.com%2Foauth_playground%2Findex.php", oauth_signature_method="HMAC-SHA1", oauth_signature="4J5faUujE0VNaybyvFCiEPY7DQ8%3D" HTTP/1.1 400 Bad Request Content-Type: text/plain; charset=UTF-8 Date: Fri, 13 May 2011 19:44:55 GMT Expires: Fri, 13 May 2011 19:44:55 GMT Cache-Control: private, max-age=0 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Content-Length: 451 Server: GSE **signature_invalid** base_string:GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_callback%3Dhttp%253A%252F%252Fgooglecodesamples.com%252Foauth_playground%252Findex.php%26oauth_consumer_key%3Dxxxxxx.appspot.com%26oauth_nonce%3D168cf60a94caa38e2defdcedd9de9%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1305315895%26oauth_version%3D1.0%26scope%3Dhttps%253A%252F%252Fmail.google.com%252Fmail%252Ffeed%252Fatom
最终更新
有两件事导致400.首先,应用程序没有注册.Google的文档说这是可选的,但事实并非如此.其次,请求没有正确签署. 这是一个出色的调试工具来测试您的OAuth请求:Oauth Playground