for any info/changes follow me: @nickmilon

twtPyCurl.py.oauth module

a small foot print oauth module

twtPyCurl.py.oauth.OAuth(application, user=None, **kwargs)[source]

a function to abstract OAuth1 / OAuth2 classes (more efficient than a class factory)

Parameters:
  • application (str) – application name
  • user (str) – user name
  • kwargs (dict) – arguments to be passed to OAuth class
Returns:

  • an OAuth2 class instance if user is None
  • an OAuth1 class instance if user is not None

class twtPyCurl.py.oauth.OAuth2(**kwargs)[source]

Bases: object

authstr = 'Authorization: Bearer %s'
__init__(**kwargs)[source]
get_oath_header(*args)[source]
Returns:an OAuth 2 header
class twtPyCurl.py.oauth.OAuth1(callback_uri=None, signature_method=u'HMAC-SHA1', signature_type=u'AUTH_HEADER', rsa_key=None, verifier=None, decoding='utf-8', **kwargs)[source]

Bases: object

gets an OAuth 1 (RFC5849) header

authstr = 'Authorization'
__init__(callback_uri=None, signature_method=u'HMAC-SHA1', signature_type=u'AUTH_HEADER', rsa_key=None, verifier=None, decoding='utf-8', **kwargs)[source]
get_oath_header(url, http_method, parms)[source]

call it to get a recalculated OAuth1 header

Parameters:
  • url (str) – request URL
  • http_method (str) – request method GET|POST|PUT etc.......
  • parms (dict) – request parameters
Returns:

an OAuth 1 header