Skip to main content

API for managing stored OAuth credentials.

Reason this release was yanked:

Deprecated

Project description

Python Library for storing OAuth credentials in many locations

What's this for?

By their very nature, OAuth credentials are valuable and dangerous, and have to be stored securely. As a result, the same tasks to store these tokens in a simple and secure fashion have to be written each time, or copied and pasted around - leading to potential issues as problems are found and not fixed in all places.

This library will store OAuth tokens in any of the following places:

  1. Secret Manager
  2. Firestore
  3. Google Cloud Storage files
  4. A local json file

Other storage locations can be added at will simply by forking this library and extending the appropriate abstract classes.

Initial Setup And Installation

Examples

Fetching a token from storage

from auth.credentials_helpers import encode_key
from auth.secret_manager import SecretManager

manager = SecretManager(project='<gcp project name>')
key = manager.get_document(encode_key('<token id>'))

Note the use of encode_key. This is because many of the storage systems supported do not allow special characters, and the most convenient identifier for most OAuth tokens is the email address of the user. encode_key is a base64 encoder - and no decoding is necessary.

The example given uses Secret Manager (part of Google Cloud). To use (say) GCS, the code would change like this:

from auth.credentials_helpers import encode_key
from auth.gcs_datastore import GCSDatastore

manager = GCSDatastore(project='<gcp project name>', bucket='<gcs bucket>')
key = manager.get_document(encode_key('<token id>'))

All that changes is where the datastore is!

Storing a token in Secret Manager

from auth.secret_manager import SecretManager
manager = SecretManager(project='<gcp project name>')

manager.update_document(id=encode_key('<token_id>'), new_data=<token string>)

This will implicitly create a secret if there was not one already, or simply update an existing secret with a new 'live' version of the secret.

Listing all the available secrets

from auth.secret_manager import SecretManager
manager = SecretManager(project='<gcp project name>')

manager.list_documents()

Removing a secret

from auth.secret_manager import SecretManager
manager = SecretManager(project='<gcp project name>')

manager.delete_document(id=encode_key('<token_id>'))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_oauth_token_manager-0.4.4.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

python_oauth_token_manager-0.4.4-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file python_oauth_token_manager-0.4.4.tar.gz.

File metadata

File hashes

Hashes for python_oauth_token_manager-0.4.4.tar.gz
Algorithm Hash digest
SHA256 94bd49357eedc87815f33896c0e27a5a15713ce70c4364b8e953782a63952782
MD5 29c060424ff5cb037b605d9f7d40169b
BLAKE2b-256 4b6f2a6b673e5922f7440cd874d4aec06c0d8d3899753bee4e820b10bd1c9e89

See more details on using hashes here.

File details

Details for the file python_oauth_token_manager-0.4.4-py3-none-any.whl.

File metadata

File hashes

Hashes for python_oauth_token_manager-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 138fe24783e3a682942d47a625a8a8f0054b648073b72f39db2bd4db8ec3d60c
MD5 7ea6209f292027e8b2924009d2af0250
BLAKE2b-256 d8fbdcd7a8e749b2383e8161dd382d94d055b661eaa145b86ab4e5724e063918

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page