Skip to main content

Build status License Code coverage CodeQL PyPI

obi-auth

obi-auth is a library for retrieving Keycloak access tokens interactively. It helps developers and testers quickly authenticate against Keycloak without writing scripts or configuring complex clients.

Installation

Basic Installation

pip install obi-auth

CLI Support

To use the obi-auth command-line interface:

pip install obi-auth[cli]

This installs click which is required by the CLI.

Notebook Support

For enhanced Jupyter notebook support with Rich display integration:

pip install obi-auth[notebook]

This installs rich (better rendering in Jupyter notebooks) and the dependencies for the interactive sign-in widget (ipyauth-pkce and jupyter-ui-poll), enabling auth_mode="notebook" (see Examples).

Examples

from obi_auth import get_token

access_token = get_token(environment="staging")
access_token = get_token(environment="staging", token_provider="auth_manager")

# Interactive sign-in from a Jupyter notebook cell (requires the `notebook`
# extra and JupyterLab). Renders a "Sign In" widget, blocks until you sign in,
# then returns the token string -- a drop-in change from auth_mode="daf":
access_token = get_token(environment="staging", auth_mode="notebook")

# Mint from an existing auth-manager persistent id (e.g. obi-one launch scripts):
access_token = get_token(
    environment="staging",
    auth_mode="persistent_token",
    persistent_token_id="<uuid>",
)

CLI

After installing with the cli extra, the obi-auth command is available. Run obi-auth --help for the full list of commands and options.

get-token

Authenticate and print the access token to stdout. Output is a single token string, suitable for piping into other commands.

obi-auth get-token
obi-auth get-token -e production -m daf
obi-auth get-token -p auth_manager
obi-auth get-token -m persistent_token --persistent-token-id <uuid>
obi-auth get-token --force-refresh
Option Description
-e, --environment Target environment: staging (default) or production
-m, --auth-mode Authentication method: pkce (default), daf, or persistent_token
-p, --token-provider Token issuer: keycloak (default) or auth_manager
--persistent-token-id Persistent token id (required when --auth-mode persistent_token)
--force-refresh Clear the cached token and authenticate again

decode-token

Decode a JWT and print the payload as indented JSON. Pass the token as an argument or via stdin.

obi-auth decode-token eyJhbGciOi...
obi-auth get-token | obi-auth decode-token
obi-auth get-token | obi-auth decode-token | jq -r '.sub'

get-user-info

Authenticate, fetch user info from Keycloak, and print the result as indented JSON.

obi-auth get-user-info
obi-auth get-user-info -e production -m daf
obi-auth get-user-info -p auth_manager
obi-auth get-user-info --force-refresh
obi-auth get-user-info | jq -r '.sub'
Option Description
-e, --environment Target environment: staging (default) or production
-m, --auth-mode Authentication method: pkce (default), daf, or persistent_token
-p, --token-provider Token issuer: keycloak (default) or auth_manager
--persistent-token-id Persistent token id (required when --auth-mode persistent_token)
--force-refresh Clear the cached token and authenticate again

Global options

Option Description
--log-level Logging level: DEBUG, INFO, WARNING (default), ERROR, CRITICAL

License

Copyright (c) 2025 Open Brain Institute

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for obi-auth 1.3.0

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

Source distribution (sdist)

Source distribution for obi-auth 1.3.0
File Size Uploaded Provenance Actions
obi_auth-1.3.0.tar.gz 39.8 kB With provenance Details for obi_auth-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for obi-auth 1.3.0
File Interpreter ABI Platform Actions
obi_auth-1.3.0-py3-none-any.whl Python 3 none any Details for obi_auth-1.3.0-py3-none-any.whl

Total release size: 67.3 kB

Release files / obi_auth-1.3.0.tar.gz

Download URL obi_auth-1.3.0.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8fbbcfd2352743b0f91dc34851ac3117b8d595dec623c265ac53ad163c71edaf
BLAKE2b-256 checksum
How to use checksums
b49d57d4bc352c6b47949a672dbaac01610a8d103ce47797ebbe31e64a98783a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / obi_auth-1.3.0-py3-none-any.whl

Download URL obi_auth-1.3.0-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
812d7f1a922120ff622ef5d5fd3adeffef7ef4df8184882d9d66b337a1f38091
BLAKE2b-256 checksum
How to use checksums
56ac478d46ded85e11fbdccf82777dc587c83ad8f45d46f012742b24149e213e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for obi-auth 1.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for obi_auth-1.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

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