python-oauth2:Python語言的OAuth2的實現
一個經全面測試,用于創建OAuth的客戶端和服務器抽象接口。
- 100% unit test coverage.
- The
DataStore
object has been completely ripped out. While creating unit tests for the library I found several substantial bugs with the implementation and confirmed with Andy Smith that it was never fully baked. - Classes are no longer prefixed with
OAuth
. - The
Request
class now extends fromdict
. - The library is likely no longer compatible with Python 2.3.
- The
Client
class works and extends fromhttplib2
. It's a thin wrapper that handles automatically signing any normal HTTP
</ul>
import oauth2 as oauth import time # Set the API endpoint url = "http://example.com/photos" # Set the base oauth_* parameters along with any other parameters required # for the API call. params = { 'oauth_version': "1.0", 'oauth_nonce': oauth.generate_nonce(), 'oauth_timestamp': int(time.time()) 'user': 'joestump', 'photoid': 555555555555 } # Set up instances of our Token and Consumer. The Consumer.key and # Consumer.secret are given to you by the API provider. The Token.key and # Token.secret is given to you after a three-legged authentication. token = oauth.Token(key="tok-test-key", secret="tok-test-secret") consumer = oauth.Consumer(key="con-test-key", secret="con-test-secret") # Set our token/key parameters params['oauth_token'] = token.key params['oauth_consumer_key'] = consumer.key # Create our request. Change method, etc. accordingly. req = oauth.Request(method="GET", url=url, parameters=params) # Sign the request. signature_method = oauth.SignatureMethod_HMAC_SHA1() req.sign_request(signature_method, consumer, token)
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!