Skip to main content

python_jam

Build Status

An asynchronous python implementation of Just Authenticate Me's REST Api.

Installation

Install normally from pypi.org:

pip install python-jam

It depends on aiohttp, so if aiohttp is installed with extras or speedups, those will be used automatically. It will also use ujson for serialization if installed. ( Defaults to build-in json)

Basic Usage

Create the JustAuthenticateMe object by supplying the AppId from you Just Authenticate Me app, then call the corresponding functions as needed. The primary ones are in the example below.

from python_jam import (
    JustAuthenticateMe, JAMUnauthorized, JAMBadRequest,
    JAMNotVerified
)

jam = JustAuthenticateMe('APP_ID')

try:
    await jam.authenticate('user@example.com')
except JAMBadRequest as e:
    print("Something went wrong", e)

try:
    headers, claims = await jam.verify_token('user_id_token')
except JAMNotVerified:
    print("Unauthorized, invalid token")

try:
    new_token = await jam.refresh('user_refresh_token')
except JAMBadRequest as e:
    print("Refresh not allowed", e)
except JAMUnauthorized:
    print("invalid refresh token")

Available Methods

These are the methods available on a JustAuthenticateMe instance. All Exception inherit from JustAuthenticateMeError. This is also the exception raised by an unexpected error. If the JustAuthenticateMe api returns a message with the error, that is passed through as exception text.

  • jam.authenticate(email) - Initialize authentication flow for a user given an email address. Returns None on success. Raises JAMBadRequest when a 400 bad request is received from justauthenticate.me (usually an invalid email) or JAMNotFound When a 404 not found is received back from justauthenticate.me

  • jam.verify_token(id_token) - Verify a JustAuthenticateMe token against jwks (loaded lazily). Call with parameter id_token (jwt) from JustAuthenticateMe. Returns headers, claims: headers and claims encoded in the user jwt. (passed through from python-jwt) or raises JAMNotVerified if verification fails on a token.

  • jam.refresh(refresh_token) - Refresh id tokens with refresh token. refresh_token: user's refreshToken from JustAuthenticateMe. Returns: new idToken (JWT) from JustAuthenticateMe. Raises JAMBadRequest when app doesn't allow refresh or request is malformed. Raises JAMInvalid when the refresh token was invalid. Raises JAMNotFound when the appId or refresh token was not found.

  • jam.delete_refresh_token(id_token, refresh_token) - Delete a user's refresh token. (i.e. logout) Called with id_token: User's id token (JWT) from Just Authenticate Me, and refresh_token: The refresh token to delete. Returns None or raises JAMUnauthorized when the id_token is invalid or JAMNotFound when the refresh_token or app_id cannot be found

  • jam.delete_all_refresh_tokens(id_token) - Delete all of a user's refresh tokens. (i.e. logout) Called with id_token: User's id token (JWT) from Just Authenticate Me. Returns None or raises JAMUnauthorized when the id_token is invalid.

Metadata

Release files for python-jam 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-jam 1.0.1
File Size Uploaded Provenance Actions
python-jam-1.0.1.tar.gz 3.9 kB Without provenance Details for python-jam-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-jam 1.0.1
File Interpreter ABI Platform Actions
python_jam-1.0.1-py3-none-any.whl Python 3 none any Details for python_jam-1.0.1-py3-none-any.whl

Total release size: 7.7 kB

Release files / python-jam-1.0.1.tar.gz

Download URL python-jam-1.0.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
af430ac07e2771460583e0a1060d0fbb150288207fdc18b51755a3c1fd07b44f
BLAKE2b-256 checksum
How to use checksums
075ef064b2baa730e4f732b7f4a1774da3bbed666f8f0840a4143efd6c7983c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Linux/5.8.0-28-generic

Release files / python_jam-1.0.1-py3-none-any.whl

Download URL python_jam-1.0.1-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8bc8d7e2a31f32becb8d04619472a3fbe61f70b0fc7e2fb3aa72b33214100ca5
BLAKE2b-256 checksum
How to use checksums
384a77c86eef193445b4df5520da735e621ef144b6e0dc6d47edfdf9d327c026
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Linux/5.8.0-28-generic

Security for python-jam 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page