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 hashes)
Built Distribution
Close
Hashes for stups_tokens-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d385160264d14752283be74913396238fc754e79d6b7e310ce888eb33fbd47b |
|
MD5 | 6c7c254a18b6ce239ed310a135c38836 |
|
BLAKE2b-256 | eeae0baf1da798049f2bf886d469ac7874a4ca3c412cb38deda373bee3f30bb7 |