Skip to main content

A small but handy module and script to load/save tokens from/to disk.

It does:

  • Save tokens in a file in disk, pickled and zipped

  • Change the file to read-only, and only by yourself

  • Load the tokens from disk

In which case this module is useful? Say you have a script or program that needs to use some secret tokens (mail auth, twitter tokens, DB connection info, etc…), but you don’t want to include those tokens in the code, because it is public, so with this module you do:

tokens = infoauth.load(os.path.expanduser("~/.my-tokens"))

Note that the file will remain only readable by yourself, and not in the project directory (so you don’t have the risk of sharing it by accident).

WARNING: it does NOT protect your secrets with any key or anything, this module does NOT secure your secrets in any way. Yes, the tokens are scrambled (because pickled and zipped) and other people may not be able to access them easily (readable only by you), but no further protection is implemented. Use at your own risk.

How to use it from a Python program?

Load your tokens:

import infoauth
auth = infoauth.load(os.path.expanduser("~/.my-mail-auth"))
# ...
mail.auth(auth['user'], auth['password'])

Dump some secrets:

import infoauth
secrets = {'some-stuff': 'foo', 'code': 67}
infoauth.dump(secrets, os.path.expanduser("~/.secrets"))

Note that as storing the secret tokens is normally done once, it’s surely handier to do it from the command line, as shown in the next section.

How to use it from the command line?

Show the tokens:

$ infoauth show ~/.my-mail-auth
password: ...
user: ...

Create a file with your secrets:

$ infoauth create ~/.secrets some-stuff=foo code=67

Note that creating the file from the command line has the limitation of all values stored being strings (if you want to store other data types, as integers, lists or any custom objects, you would need to use the programmatically way of dumping your secrets to disk, as shown in the previous section).

Metadata

Release files for infoauth 1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for infoauth 1.5
File Size Uploaded
infoauth-1.5.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for infoauth 1.5
File Interpreter ABI Platform
infoauth-1.5-py3-none-any.whl Python 3 none any Details

Total release size: 34.6 kB

Release files / infoauth-1.5.tar.gz

Download URL infoauth-1.5.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bdbcfe7a354d56ec3619dab4d71c878df766b77607356e201eb601edba4bfab6
BLAKE2b-256 checksum
How to use checksums
d9ae924d6232b15d850a8db7caf11426a50ab74d246eeb7722857c652727a5a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / infoauth-1.5-py3-none-any.whl

Download URL infoauth-1.5-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16a971665dff4159b0b4381287b3b2eae90c21bdfedcb5b5dcda5270d781f176
BLAKE2b-256 checksum
How to use checksums
3b49b77788f77173c267ab13f9a866221bd0bef4102df951209cb7f607fb34a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.5 This release

2 release files

1.4

1 release file

1.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page