michaelliao / sinaweibopy

新浪微博Python SDK
http://michaelliao.github.com/sinaweibopy/
Apache License 2.0
1.27k stars 504 forks source link

获取access_token,服务器返回Bad Request #54

Open TrigoldenZx opened 9 years ago

TrigoldenZx commented 9 years ago

使用SDK中的方法去获取access_token,服务器返回Bad Request,有谁知道是哪里有问题吗?

代码如下: import urllib2 import urllib from snspy import APIClient from snspy import SinaWeiboMixin

def wbAPItest(): client = APIClient(SinaWeiboMixin, app_key=appkey, app_secret=appsec, redirect_uri=redirurl) url = client.get_authorize_url() r = client.request_access_token(authcode) access_token = r.access_token # access token,e.g., abc123xyz456 expires = r.expires

if name=='main': httpHandler = urllib2.HTTPHandler(debuglevel=1) httpsHandler = urllib2.HTTPSHandler(debuglevel=1) opener = urllib2.build_opener(httpHandler, httpsHandler) urllib2.install_opener(opener) wbAPItest()

运行后日志: ERROR:root:POST: https://api.weibo.com/oauth2/access_token send: 'POST /oauth2/access_token HTTP/1.1\r\nContent-Length: 204\r\nAccept-Encoding: gzip\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\nHost: api.weibo.com\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nclient_secret=b6745a6318f713f8f00b8d715927fab5&code=b0d87cc1e249a30626b82549376d830e&grant_type=authorization_code&client_id=2066080083&redirect_uri=http%3A//open.weibo.com/apps/2066080083/privilege/oauth'

reply: 'HTTP/1.1 400 Bad Request\r\n' header: Server: nginx/1.6.1

header: Date: Tue, 19 May 2015 08:47:05 GMT

header: Transfer-Encoding: chunked

header: Connection: close

header: Pragma: No-cache

header: Cache-Control: no-cache

header: Expires: Thu, 01 Jan 1970 00:00:00 GMT

header: Api-Server-IP: 10.75.25.115

duoluoxiaosheng commented 7 years ago

我也遇到同样的为题,解决了吗