【发布时间】:2018-07-29 20:18:01
【问题描述】:
我正在尝试使用 Python/pycurl 验证一个在 stocktwits (see API) 上发布的机器人。据我了解,首先我需要通过oauth/authorize 请求应用程序被授权使用Stocktwits 用户数据,这将返回一个授权码。然后我需要通过oauth/token 确认权限,这将发送回一个可用于发布股票推文的访问令牌。
我遇到的问题是,在我向auth/authorize 发出 post 请求后,返回的响应是
Host: api.stocktwits.com
Authorization: Basic bmljay5vc2hpbm92QGdtYWlsLmNvbTp6YWRuaWsxMg==
User-Agent: PycURL/7.43.0.2 libcurl/7.60.0 OpenSSL/1.1.0h zlib/1.2.11 c-
ares/1.14.0 WinIDN libssh2/1.8.0 nghttp2/1.32.0
Accept: */*
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
< HTTP/1.1 100 Continue
程序只是停止等待。如何处理http 100 响应?
api调用代码如下
def get_auth_token:
auth_data = ""
c = pycurl.Curl()
c.setopt(c.CAINFO, self.CA_CERTS)
c.setopt(pycurl.POST, 1)
c.setopt(c.URL, uri_to_ouath_authorize_call)
c.setopt(c.FOLLOWLOCATION, True)
c.setopt(c.WRITEDATA, auth_data)
c.setopt(c.USERPWD, 'bot_account_username:password')
【问题讨论】:
-
在上面的
Authorization标头中,您的用户名:密码base64 编码(所以基本上是明文),如果您忘记修改它,我建议删除这个问题并重新创建一个没有原始值
标签: python curl oauth-2.0 pycurl