Skip to main content

A toolset for the most requirements dealing with OAuth2 and OpenID Connect.

Project description

OAuth2Tools

A toolset for the most requirements dealing with OAuth2 and OpenID Connect.

Samples

Building the URL for the authentication endpoint

from oauth2tools import OAuthTools

tools = OAuthTools(
    well_known_url="<url>", 
    client_id="<cid>", 
    client_secret="<secret>")
auth_url = tools.authorization_url(redirect_uri="<uri>")

Using the Browser in a CLI script for authentication

from oauth2tools import OAuth4CLI

o4c = OAuth4CLI(
    well_known_url="<url>", 
    client_id="<cid>", 
    client_secret="<secret>")
response = o4c.login()
access_token = response.get('access_token')

Validate an received token

from oauth2tools import jwt_helper

try:
    jwt_helper.validate_by_jwks(
        token="<jwt>", 
        jwks_url="<jwks_url>",
        claims={"<claim_name>": "expected_value"})
except Exception as e:
    ...

Project details


Download files

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

Source Distribution

oauth2tools-0.8.1.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

oauth2tools-0.8.1-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page