Python中的Identi.ca Oauth
我正在尝试在Identi.ca上完成Oauth身份验证。基本上,我尝试使用与Twitter相同的代码,但是,当然,更改URL。我甚至无法获取请求令牌,因为HTTP错误400:Bad request,如下所示。我真的很想知道我做错了什么,或者与推特的做法有什么不同。到目前为止,我得到的是:Python中的Identi.ca Oauth,python,oauth,identica,Python,Oauth,Identica,我正在尝试在Identi.ca上完成Oauth身份验证。基本上,我尝试使用与Twitter相同的代码,但是,当然,更改URL。我甚至无法获取请求令牌,因为HTTP错误400:Bad request,如下所示。我真的很想知道我做错了什么,或者与推特的做法有什么不同。到目前为止,我得到的是: from oauth import oauth import urllib2 class IdenticaOauth: def __init__(self): self.request_token
from oauth import oauth
import urllib2
class IdenticaOauth:
def __init__(self):
self.request_token_url = 'https://identi.ca/api/oauth/request_token'
self.access_token_url = 'https://identi.ca/api/oauth/access_token'
self.authorize_url = 'https://identi.ca/api/oauth/authorize'
self.consumer_key = '8024d4db70d9e49d22728f25b4c1458b'
self.consumer_secret = '4eb762cfe3c0a55950375dad795cf20e'
self.consumer = oauth.OAuthConsumer(self.consumer_key, self.consumer_secret)
self.signature_method = oauth.OAuthSignatureMethod_HMAC_SHA1()
def get_unauthorized_request_token(self):
oauth_request = oauth.OAuthRequest.from_consumer_and_token(self.consumer, http_url = self.request_token_url)
oauth_request.sign_request(self.signature_method, self.consumer, None)
url = oauth_request.to_url()
response = self.get(url)
token = oauth.OAuthToken.from_string(response)
return token
def get(self, url):
request = urllib2.Request(url)
# urllib2.HTTPError: HTTP Error 400: Bad Request
response = urllib2.urlopen(request)
return response.read()
identica_oauth = IdenticaOauth()
request_token = identica_oauth.get_unauthorized_request_token()
我尝试使用callback='oob',因为Identi.ca正在使用Oauth 1.0a(如上所述),但它返回401个未经授权的错误。