我正在嘗試使用instapaper API,但我一直在爲我的請求收到403錯誤。代碼如下:instapaper和oauth - 403「Not logged in」錯誤
consumer_key='...'
consumer_secret='...'
access_token_url = 'https://www.instapaper.com/api/1/oauth/access_token'
consumer = oauth.Consumer(consumer_key, consumer_secret)
client = oauth.Client(consumer)
client.add_credentials('...','...')
params = {}
params["x_auth_username"] = '..'
params["x_auth_password"] = '...'
params["x_auth_mode"] = 'client_auth'
client.set_signature_method = oauth.SignatureMethod_HMAC_SHA1()
resp, token = client.request(access_token_url, method="POST",body=urllib.urlencode(params))
result = simplejson.load(urllib.urlopen('https://www.instapaper.com/api/1/bookmarks/list?' + token))
任何想法?
你需要你的訪問之前得到請求令牌令牌 – jterrace
API文檔(http://www.instapaper.com/api/full)說,不需要請求令牌。 – pnsilva
啊,我明白了。 ''client.request''返回的''token'是否有效?你應該直接使用OauthRequest而不是urllib.urlopen。請參閱https://github.com/simplegeo/python-oauth2/blob/master/example/client.py#L145-156 – jterrace