Skip to main content

Validate and extract information from OAuth2 token.

Project description

Validate and extract information from OAuth2 token

pypi version Build status Coverage Code style: black Number of tests Number of downloads

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

  1. python 3.6+ must be installed
  2. Use pip to install module:
python -m pip install oauth2helper

Project details


Release history Release notifications

This version

3.3.0

Download files

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

Files for oauth2helper, version 3.3.0
Filename, size File type Python version Upload date Hashes
Filename, size oauth2helper-3.3.0-py3-none-any.whl (5.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size oauth2helper-3.3.0.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page