oauth2client.multistore_file module¶
Multi-credential file store with lock support.
This module implements a JSON credential store where multiple credentials can be stored in one file. That file supports locking both in a single process and across processes.
The credential themselves are keyed off of:
- client_id
- user_agent
- scope
The format of the stored data is like so:
{
'file_version': 1,
'data': [
{
'key': {
'clientId': '<client id>',
'userAgent': '<user agent>',
'scope': '<scope>'
},
'credential': {
# JSON serialized Credentials.
}
}
]
}
-
exception
oauth2client.multistore_file.
Error
[source]¶ Bases:
exceptions.Exception
Base error for this module.
-
exception
oauth2client.multistore_file.
NewerCredentialStoreError
[source]¶ Bases:
oauth2client.multistore_file.Error
The credential store is a newer version than supported.
-
oauth2client.multistore_file.
get_all_credential_keys
(*args, **kwargs)[source]¶ Gets all the registered credential keys in the given Multistore.
Parameters: - filename – The JSON file storing a set of credentials
- warn_on_readonly – if True, log a warning if the store is readonly
Returns: A list of the credential keys present in the file. They are returned as dictionaries that can be passed into get_credential_storage_custom_key to get the actual credentials.
-
oauth2client.multistore_file.
get_credential_storage
(*args, **kwargs)[source]¶ Get a Storage instance for a credential.
Parameters: - filename – The JSON file storing a set of credentials
- client_id – The client_id for the credential
- user_agent – The user agent for the credential
- scope – string or iterable of strings, Scope(s) being requested
- warn_on_readonly – if True, log a warning if the store is readonly
Returns: An object derived from client.Storage for getting/setting the credential.
-
oauth2client.multistore_file.
get_credential_storage_custom_key
(*args, **kwargs)[source]¶ Get a Storage instance for a credential using a dictionary as a key.
Allows you to provide a dictionary as a custom key that will be used for credential storage and retrieval.
Parameters: - filename – The JSON file storing a set of credentials
- key_dict – A dictionary to use as the key for storing this credential. There is no ordering of the keys in the dictionary. Logically equivalent dictionaries will produce equivalent storage keys.
- warn_on_readonly – if True, log a warning if the store is readonly
Returns: An object derived from client.Storage for getting/setting the credential.
-
oauth2client.multistore_file.
get_credential_storage_custom_string_key
(*args, **kwargs)[source]¶ Get a Storage instance for a credential using a single string as a key.
Allows you to provide a string as a custom key that will be used for credential storage and retrieval.
Parameters: - filename – The JSON file storing a set of credentials
- key_string – A string to use as the key for storing this credential.
- warn_on_readonly – if True, log a warning if the store is readonly
Returns: An object derived from client.Storage for getting/setting the credential.