Validate and extract information from OAuth2 token.
Project description
Validate and extract information from OAuth2 token
Provides:
- Validation of OAuth2 token
- Extraction of data from validated (or decoded) token.
Validating an OAuth2 token
import oauth2helper
headers = {"Authorization": "Bearer YOUR_OAUTH2_TOKEN"}
my_token = headers.get('Authorization')[7:]
# Will raise InvalidTokenError or InvalidKeyError in case validation failed
oauth2helper.validate(my_token, "https://provider_url/common/discovery/keys")
Extracting user from a OAuth2 token
import oauth2helper
headers = {"Authorization": "Bearer YOUR_OAUTH2_TOKEN"}
my_token = headers.get('Authorization')[7:]
json_header, json_body = oauth2helper.validate(my_token, "https://provider_url/common/discovery/keys")
username = oauth2helper.user_name(json_body)
How to install
- python 3.6+ must be installed
- Use pip to install module:
python -m pip install oauth2helper
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
oauth2helper-3.3.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for oauth2helper-3.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd9f975ecc5c7b85b1cefc524f71165fb67d6854d8d3661a799347bb58be0544 |
|
MD5 | 59876ef107d213e101c6d7a7d67173bb |
|
BLAKE2b-256 | 4c056e6c01ef125908c50ff0f3e6ee680457bb025fa40a9cc9cfd846a30eb817 |