Skip to main content

Add your description here

Project description

oidc-auth-client

Build and Publish

Pure python implementation of an OIDC client

Dependencies:

Installing

pip install oidc-auth-client

Example usage

Authorization Code Flow

Use this flow when your application needs to authenticate a real user.

It will:

  1. Open the user’s browser
  2. Redirect them to your identity provider’s login page
  3. Wait for the user to authenticate
  4. Receive an authorization code
  5. Exchange it for an access token

Best for CLIs, desktop apps, and tools acting on behalf of a user.

from oidc_auth_client import Config, AuthorizationCode, OidcProvider

config = Config(
    client_id="<your-client-id>",
    oidc_provider=OidcProvider(
        openid_configuration_url="<auth-provider-url>/.well-known/openid-configuration"
    )
)

# Sign in with the identity provider in the opened browser!
access_token = AuthorizationCode(config=config).get_token()

Client Credentials Flow

Use this flow when your application needs to authenticate as itself, without user interaction. The client exchanges its own client_id and client_secret directly for an access token.

Ideal for:

  • Backend services
  • Server-to-server APIs
  • Cron jobs
  • Automated tasks
from oidc_auth_client import ClientCredentials, OidcProvider, TokenCache
from oidc_auth_client.client_credentials import ClientCredentialsConfig

config = ClientCredentialsConfig(
    client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,
    oidc_provider=OidcProvider(openid_configuration_url=OPENID_CONFIGURATION_URL),
)

access_token = ClientCredentials(config=config).get_token()

Token caching between runs

To allow the user to cache the token between usages, configure with a TokenCache. Will store the token in plaintext on the users system.

from oidc_auth_client import Config, TokenCache

config = Config(
    # ...
    token_cache=TokenCache(),
)

see some example usage in the examples folder.

Contributing

Requirements:

  • uv ^0.7.22

Setup:

uv sync

Run tests:

uv run pytest .

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

oidc_auth_client-0.1.6.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oidc_auth_client-0.1.6-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file oidc_auth_client-0.1.6.tar.gz.

File metadata

  • Download URL: oidc_auth_client-0.1.6.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oidc_auth_client-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5e13b45869aab2bdcc7e820fb5148e0d602ad0f91183d5839a97aa6650235d2c
MD5 5461012562eafe4bf8ffc65712dbfcba
BLAKE2b-256 e85730cbab2e7a2ff0436d1da1eaf276bc18a24ad01f4ddac42ba6ba676c60c9

See more details on using hashes here.

File details

Details for the file oidc_auth_client-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: oidc_auth_client-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oidc_auth_client-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b604efc9e3a62e2b4587ebf419f44ea43e66eea5cf38d626e955d4a075a275de
MD5 3884d3f5eb362692b403d34ce5adec89
BLAKE2b-256 e8df9640889c53c4224afe07a8ae7a99efaf4f4f6e267ed7aab47d1021d38c81

See more details on using hashes here.

Supported by

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