No project description provided
Project description
sophi-app-internal
Python Package
Overview
sophi-app-internal is a Python package designed to facilitate secure and authenticated HTTP request handling, particularly in environments where JWT (JSON Web Token) authentication is used. The package includes utilities for validating JWTs, fetching public keys, and constructing HTTP request objects with robust header and parameter management.
Features
JWT validation and verification using Auth0. Secure fetching of JSON Web Key Sets (JWKS). Construction and management of HTTP request objects with headers, parameters, and body handling. Installation To install the sophi-app-internal package, use the following command:
pip install sophi-app-internal
Token Validator Usage
Setting Up Variables
Before using the package, ensure you have set up the necessary variables:
- AUTH0_DOMAIN: Your Auth0 domain, e.g.
<tenant>.us.auth0.com
. - AUDIENCE: The expected token audience. You need to register your API on Auth0 before getting a valid audience value.
You can set these variables in your environment:
auth0_domain = "app-dev.us.auth0.com"
audience = [
"https://api.example.com/",
"https://website.us.auth0.com/userinfo"
]
token = "<your token>"
Note: ensure you pass the token after parsing the Authorization
header and removing the Bearer
keyword.
Example Code
Validating JWTs Here's an example of how to validate a JWT using the token_validator function.
from sophi_app_internal import token_validator
try:
claims = token_validator(token, audience, auth0_domain)
print(claims)
except Exception as e:
print(e)
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
Built Distribution
Hashes for sophi_app_internal-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b769806b526fda4841ae0ef31432b224db467eed5746fc07703b1e479affa78d |
|
MD5 | 981a9b2fe806bc6b821168edc18a98fe |
|
BLAKE2b-256 | 1d9b718e479da937b32c3dcc45b1300ac1d6491a8b21978ffe9aa2c8220e7abd |