我试图让Oauth使用Python使用Google API.我尝试了不同的oauth库,如oauth,oauth2和djanog-oauth,但我无法使其工作(包括提供的示例).
为了调试Oauth,我使用了Google的Oauth Playground,我研究了API和Oauth文档
对于一些库我正在努力获得正确的签名,与其他库我正在努力将请求令牌转换为授权令牌.如果有人可以使用上述库之一向我展示Google API的工作示例,那将对我有什么帮助.
编辑:我的初步问题没有得到任何答案,所以我添加了我的代码.导致此代码无效的原因有两种:
1)Google未授权我的请求令牌,但不太确定如何检测此
签名2)访问令牌的签名无效但我想了解哪些oauth参数Google因为我能够在第一阶段产生适当的签名.
这是使用oauth2.py和Django编写的,因此是HttpResponseRedirect.
REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken'
AUTHORIZATION_URL = 'https://www.google.com/accounts/OAuthAuthorizeToken'
ACCESS_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetAccessToken'
CALLBACK = 'http://localhost:8000/mappr/mappr/oauth/' #will become real server when deployed
OAUTH_CONSUMER_KEY = 'anonymous'
OAUTH_CONSUMER_SECRET = 'anonymous'
signature_method = oauth.SignatureMethod_HMAC_SHA1()
consumer = oauth.Consumer(key=OAUTH_CONSUMER_KEY, secret=OAUTH_CONSUMER_SECRET)
client = oauth.Client(consumer)
request_token = oauth.Token('','') #hackish way to be able to access the token in different functions, I know this is bad, but I just want it …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Gmail php xoath php示例,但是它需要输入消费者密钥和消费者密钥,我无法找到如何在Gmail api文档中获取.有没有人知道如何获取或知道任何相关文件?