Python oauth2client.Credentials() Examples
The following are 30
code examples of oauth2client.Credentials().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oauth2client
, or try the search function
.
Example #1
Source File: django_orm.py From sndlatr with Apache License 2.0 | 6 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(value))
Example #2
Source File: django_orm.py From aqua-monitor with GNU Lesser General Public License v3.0 | 6 votes |
def locked_put(self, credentials, overwrite=False): """Write a Credentials to the Django datastore. Args: credentials: Credentials, the credentials to store. overwrite: Boolean, indicates whether you would like these credentials to overwrite any existing stored credentials. """ args = {self.key_name: self.key_value} if overwrite: (entity, unused_is_new) = self.model_class.objects.get_or_create(**args) else: entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #3
Source File: django_orm.py From data with GNU General Public License v3.0 | 6 votes |
def locked_put(self, credentials, overwrite=False): """Write a Credentials to the Django datastore. Args: credentials: Credentials, the credentials to store. overwrite: Boolean, indicates whether you would like these credentials to overwrite any existing stored credentials. """ args = {self.key_name: self.key_value} if overwrite: (entity, unused_is_new) = self.model_class.objects.get_or_create(**args) else: entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #4
Source File: appengine.py From alfred-gmail with MIT License | 6 votes |
def locked_get(self): """Retrieve Credential from datastore. Returns: oauth2client.Credentials """ credentials = None if self._cache: json = self._cache.get(self._key_name) if json: credentials = client.Credentials.new_from_json(json) if credentials is None: entity = self._get_entity() if entity is not None: credentials = getattr(entity, self._property_name) if self._cache: self._cache.set(self._key_name, credentials.to_json()) if credentials and hasattr(credentials, 'set_store'): credentials.set_store(self) return credentials
Example #5
Source File: django_orm.py From data with GNU General Public License v3.0 | 6 votes |
def locked_put(self, credentials, overwrite=False): """Write a Credentials to the Django datastore. Args: credentials: Credentials, the credentials to store. overwrite: Boolean, indicates whether you would like these credentials to overwrite any existing stored credentials. """ args = {self.key_name: self.key_value} if overwrite: (entity, unused_is_new) = self.model_class.objects.get_or_create(**args) else: entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #6
Source File: appengine.py From jarvis with GNU General Public License v2.0 | 6 votes |
def locked_get(self): """Retrieve Credential from datastore. Returns: oauth2client.Credentials """ credentials = None if self._cache: json = self._cache.get(self._key_name) if json: credentials = client.Credentials.new_from_json(json) if credentials is None: entity = self._get_entity() if entity is not None: credentials = getattr(entity, self._property_name) if self._cache: self._cache.set(self._key_name, credentials.to_json()) if credentials and hasattr(credentials, 'set_store'): credentials.set_store(self) return credentials
Example #7
Source File: django_orm.py From earthengine with MIT License | 6 votes |
def locked_put(self, credentials, overwrite=False): """Write a Credentials to the datastore. Args: credentials: Credentials, the credentials to store. overwrite: Boolean, indicates whether you would like these credentials to overwrite any existing stored credentials. """ args = {self.key_name: self.key_value} if overwrite: entity, unused_is_new = self.model_class.objects.get_or_create(**args) else: entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #8
Source File: appengine.py From jarvis with GNU General Public License v2.0 | 5 votes |
def validate(self, value): value = super(CredentialsProperty, self).validate(value) logger.info("validate: Got type " + str(type(value))) if value is not None and not isinstance(value, client.Credentials): raise db.BadValueError( 'Property {0} must be convertible ' 'to a Credentials instance ({1})'.format(self.name, value)) return value
Example #9
Source File: appengine.py From jarvis with GNU General Public License v2.0 | 5 votes |
def make_value_from_datastore(self, value): logger.info("make: Got type " + str(type(value))) if value is None: return None if len(value) == 0: return None try: credentials = client.Credentials.new_from_json(value) except ValueError: credentials = None return credentials
Example #10
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(value))
Example #11
Source File: appengine.py From jarvis with GNU General Public License v2.0 | 5 votes |
def locked_put(self, credentials): """Write a Credentials to the datastore. Args: credentials: Credentials, the credentials to store. """ entity = self._model.get_or_insert(self._key_name) setattr(entity, self._property_name, credentials) entity.put() if self._cache: self._cache.set(self._key_name, credentials.to_json())
Example #12
Source File: appengine.py From jarvis with GNU General Public License v2.0 | 5 votes |
def get_credentials(self): """A thread local Credentials object. Returns: A client.Credentials object, or None if credentials hasn't been set in this thread yet, which may happen when calling has_credentials inside oauth_aware. """ return getattr(self._tls, 'credentials', None)
Example #13
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(smart_bytes(value)))
Example #14
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_get(self): """Retrieve stored credential. Returns: oauth2client.Credentials """ credential = None query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query) if len(entities) > 0: credential = getattr(entities[0], self.property_name) if credential and hasattr(credential, 'set_store'): credential.set_store(self) return credential
Example #15
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_delete(self): """Delete Credentials from the datastore.""" query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query).delete()
Example #16
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(value))
Example #17
Source File: django_orm.py From twitter-for-bigquery with Apache License 2.0 | 5 votes |
def locked_delete(self): """Delete Credentials from the datastore.""" query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query).delete()
Example #18
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_put(self, credentials): """Write a Credentials to the datastore. Args: credentials: Credentials, the credentials to store. """ args = {self.key_name: self.key_value} entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #19
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_delete(self): """Delete Credentials from the datastore.""" query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query).delete()
Example #20
Source File: django_orm.py From twitter-for-bigquery with Apache License 2.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(value))
Example #21
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_get(self): """Retrieve Credential from datastore. Returns: oauth2client.Credentials """ credential = None query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query) if len(entities) > 0: credential = getattr(entities[0], self.property_name) if credential and hasattr(credential, 'set_store'): credential.set_store(self) return credential
Example #22
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_put(self, credentials): """Write a Credentials to the datastore. Args: credentials: Credentials, the credentials to store. """ args = {self.key_name: self.key_value} entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #23
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(value))
Example #24
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_get(self): """Retrieve Credential from datastore. Returns: oauth2client.Credentials """ credential = None query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query) if len(entities) > 0: credential = getattr(entities[0], self.property_name) if credential and hasattr(credential, 'set_store'): credential.set_store(self) return credential
Example #25
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_put(self, credentials): """Write a Credentials to the datastore. Args: credentials: Credentials, the credentials to store. """ args = {self.key_name: self.key_value} entity = self.model_class(**args) setattr(entity, self.property_name, credentials) entity.save()
Example #26
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_delete(self): """Delete Credentials from the datastore.""" query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query).delete()
Example #27
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(smart_bytes(value)))
Example #28
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_delete(self): """Delete Credentials from the datastore.""" query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query).delete()
Example #29
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def to_python(self, value): if value is None: return None if isinstance(value, oauth2client.client.Credentials): return value return pickle.loads(base64.b64decode(value))
Example #30
Source File: django_orm.py From data with GNU General Public License v3.0 | 5 votes |
def locked_get(self): """Retrieve Credential from datastore. Returns: oauth2client.Credentials """ credential = None query = {self.key_name: self.key_value} entities = self.model_class.objects.filter(**query) if len(entities) > 0: credential = getattr(entities[0], self.property_name) if credential and hasattr(credential, 'set_store'): credential.set_store(self) return credential