def __init__(self, signature_method, consumer_key, consumer_secret=None, rsa_key=None): """Initializes object with parameters required for using OAuth mechanism. NOTE: Though consumer_secret and rsa_key are optional, either of the two is required depending on the value of the signature_method. Args: signature_method: class which provides implementation for strategy class oauth.oauth.OAuthSignatureMethod. Signature method to be used for signing each request. Valid implementations are provided as the constants defined by gdata.auth.OAuthSignatureMethod. Currently they are gdata.auth.OAuthSignatureMethod.RSA_SHA1 and gdata.auth.OAuthSignatureMethod.HMAC_SHA1 consumer_key: string Domain identifying third_party web application. consumer_secret: string (optional) Secret generated during registration. Required only for HMAC_SHA1 signature method. rsa_key: string (optional) Private key required for RSA_SHA1 signature method. """ if signature_method == OAuthSignatureMethod.RSA_SHA1: self._signature_method = signature_method(rsa_key, None) else: self._signature_method = signature_method() self._consumer = oauth.OAuthConsumer(consumer_key, consumer_secret)
def __init__(self): self.consumer = oauth.OAuthConsumer('a56b5ff0a637ab283d1d8e32ced37a9c', '9a3248210c84b264b56b98c0b872bc8a') self.consumer_db = {self.consumer.key: self.consumer} self.request_token_db = {} self.access_token_db = {} self.nonce = None
def setUp(self): self.consumer = oauth.OAuthConsumer('a56b5ff0a637ab283d1d8e32ced37a9c', '9a3248210c84b264b56b98c0b872bc8a') self.token = oauth.OAuthToken('5b2cafbf20b11bace53b29e37d8a673d', '3f71254637df2002d8819458ae4f6c51') self.http_url = 'http://dev.alicehub.com/server/api/newsfeed/update/' self.http_method = HTTP_METHOD_POST
def __init__(self, signature_method, consumer_key, consumer_secret=None, rsa_key=None, requestor_id=None): """Initializes object with parameters required for using OAuth mechanism. NOTE: Though consumer_secret and rsa_key are optional, either of the two is required depending on the value of the signature_method. Args: signature_method: class which provides implementation for strategy class oauth.oauth.OAuthSignatureMethod. Signature method to be used for signing each request. Valid implementations are provided as the constants defined by gdata.auth.OAuthSignatureMethod. Currently they are gdata.auth.OAuthSignatureMethod.RSA_SHA1 and gdata.auth.OAuthSignatureMethod.HMAC_SHA1. Instead of passing in the strategy class, you may pass in a string for 'RSA_SHA1' or 'HMAC_SHA1'. If you plan to use OAuth on App Engine (or another WSGI environment) I recommend specifying signature method using a string (the only options are 'RSA_SHA1' and 'HMAC_SHA1'). In these environments there are sometimes issues with pickling an object in which a member references a class or function. Storing a string to refer to the signature method mitigates complications when pickling. consumer_key: string Domain identifying third_party web application. consumer_secret: string (optional) Secret generated during registration. Required only for HMAC_SHA1 signature method. rsa_key: string (optional) Private key required for RSA_SHA1 signature method. requestor_id: string (optional) User email adress to make requests on their behalf. This parameter should only be set when performing 2 legged OAuth requests. """ if (signature_method == OAuthSignatureMethod.RSA_SHA1 or signature_method == 'RSA_SHA1'): self.__signature_strategy = 'RSA_SHA1' elif (signature_method == OAuthSignatureMethod.HMAC_SHA1 or signature_method == 'HMAC_SHA1'): self.__signature_strategy = 'HMAC_SHA1' else: self.__signature_strategy = signature_method self.rsa_key = rsa_key self._consumer = oauth.OAuthConsumer(consumer_key, consumer_secret) self.requestor_id = requestor_id
def setUp(self): self.key = 'key' self.secret = 'secret' self.consumer = oauth.OAuthConsumer(self.key, self.secret)