Python library to manage OAuth access tokens
Project description
A Python library that keeps OAuth 2.0 service access tokens in memory for your usage.
Installation
$ sudo pip3 install --upgrade stups-tokens
Usage
import requests
import time
import tokens
# will use OAUTH2_ACCESS_TOKEN_URL environment variable by default
# will try to read application credentials from CREDENTIALS_DIR
tokens.configure(url='https://example.com/access_tokens')
tokens.manage('example', ['read', 'write'])
tokens.start()
tok = tokens.get('example')
requests.get('https://example.org/', headers={'Authorization': 'Bearer {}'.format(tok)})
time.sleep(3600) # make the token expire
tok = tokens.get('example') # will refresh the expired token
requests.get('https://example.org/', headers={'Authorization': 'Bearer {}'.format(tok)})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stups-tokens-0.3.tar.gz
(2.3 kB
view details)
Built Distribution
File details
Details for the file stups-tokens-0.3.tar.gz
.
File metadata
- Download URL: stups-tokens-0.3.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc47be09c97018435ccfaf40776bc006345ce954a5130995d97daa2fe419f375 |
|
MD5 | 3f5d22e3799ac38e6f3b4b063d209d0e |
|
BLAKE2b-256 | 69924281f32855d792f4ba17645eb65b17066d6b52ae2e3a16de4d0d7b1312aa |
Provenance
File details
Details for the file stups_tokens-0.3-py3-none-any.whl
.
File metadata
- Download URL: stups_tokens-0.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d385160264d14752283be74913396238fc754e79d6b7e310ce888eb33fbd47b |
|
MD5 | 6c7c254a18b6ce239ed310a135c38836 |
|
BLAKE2b-256 | eeae0baf1da798049f2bf886d469ac7874a4ca3c412cb38deda373bee3f30bb7 |