- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试在Python中访问OAuth2(代码与 http://code.google.com/p/google-api-ads-python/source/browse/trunk/examples/adspygoogle/adwords/v201302/misc/use_oauth2.py?spec=svn139&r=139 相同):
flow = OAuth2WebServerFlow(client_id='XXX',
client_secret='YYY',
scope='https://adwords.google.com/api/adwords',
user_agent='ZZZ')
authorize_url = flow.step1_get_authorize_url('urn:ietf:wg:oauth:2.0:oob')
code = raw_input('Code: ').strip()
credential = None
try:
credential = flow.step2_exchange(code) #<- error
except FlowExchangeError, e:
sys.exit('Authentication has failed: %s' % e)
这会在 step2_exchange 处产生“socket.error: [Errno 10054]”错误,并且 Python 会截断确切的消息。因此,在使用 OAuthplayground 检查 key (以获得更好的错误消息)后,我收到此错误:
HTTP/1.1 400 Bad Request
Content-length: 37
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Via: HTTP/1.1 GWA
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Thu, 06 Jun 2013 13:54:29 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json
Expires: Fri, 01 Jan 1990 00:00:00 GMT
{
"error" : "unauthorized_client"
}
我检查了 client_id(对于已安装的应用程序)和 client_secret 是否与 Google API 控制台 ( https://code.google.com/apis/console/ ) 中指定的相同。
如果我通过 OAuthPlayground 执行整个过程,它将起作用,但如果我尝试使用 Playground 创建的 token ,应用程序也会失败。
有谁知道怎么解决吗?
最佳答案
已修复。我位于代理后面,该代理允许步骤 1 身份验证通过,但显然不允许步骤 2 身份验证。就这么简单
h = httplib2.Http(proxy_info = httplib2.ProxyInfo PROXY DATA .....)
flow.step2_exchange(code, h)
已修复。
关于python - GoogleOAuth2 身份验证失败 "unauthorized_client"/Python GoogleAdWord API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16964292/
我看到有几篇关于“无法设置属性”的帖子,但我仍在努力找出我在这里缺少的内容。我是 Javascript 和 GAS 的新手。我写过一本关于 GAS 的书,名为《GScript 企业应用程序要点》。该代
我使用 dektrium/yii2-user(在一个项目上)和 yiisoft/yii2-authclient(在另一个项目上)通过 Google 帐户登录。前段时间一切正常,但我想在上次 Compo
我是一名优秀的程序员,十分优秀!