Add your description here
Project description
oidc-auth-client
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:
- Open the user’s browser
- Redirect them to your identity provider’s login page
- Wait for the user to authenticate
- Receive an authorization code
- 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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oidc_auth_client-0.1.5.tar.gz.
File metadata
- Download URL: oidc_auth_client-0.1.5.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43ea48d34cf7c52baa927146d7fb695b5777acb92a231348be0be34197f67b77
|
|
| MD5 |
9031056052e118f1dc737280850738d9
|
|
| BLAKE2b-256 |
f77b09d5ca3555aa519f11cf1498e17c39753adced336add0d1060da2a3683df
|
File details
Details for the file oidc_auth_client-0.1.5-py3-none-any.whl.
File metadata
- Download URL: oidc_auth_client-0.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eeb860fd2917c079580f6e43f99b89f7017fda9c87ef9bc61879e2b2b38ce8df
|
|
| MD5 |
d7fb5b7eba63b88d5a4fc336ab335d89
|
|
| BLAKE2b-256 |
3343cb3131288314b4bfee0d0469f475e984e84f0922fe3be9e620b4c759803a
|