Registry / auth-security / oauth-cli-kit

oauth-cli-kit

JSON →
library0.1.3pypypi✓ verified 88d ago

oauth-cli-kit (version 0.1.3) provides reusable helpers for implementing the OAuth 2.0 Authorization Code Grant flow with PKCE (Proof Key for Code Exchange) in command-line applications. It simplifies the process by handling browser interaction for user authorization and setting up a temporary local server for the redirect URI callback. The library aims for a stable release cadence but is currently in early development (0.x.x), meaning API changes are possible.

pip install oauth-cli-kit
INSTALL
IMPORT
SIG · OAUTH-CLI-KIT
O
oauth-cli-kit
auth-securitypythonv0.1.3
Install
2.2s avg
Import
—
Disk
19MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✓ —
✓ 2.35s
py 3.12
✓ —
✓ 2.15s
py 3.13
✓ —
✓ 2s
py 3.9
✕ build_error
✕ build_error
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OAuthProviderConfig
✓ from oauth_cli_kit import OAuthProviderConfig
✗ from oauth_cli_kit import OAuthCliApp
OAuthToken
✓ from oauth_cli_kit import OAuthToken
login_oauth_interactive
✓ from oauth_cli_kit import login_oauth_interactive

This quickstart demonstrates how to initiate an OAuth 2.0 PKCE flow using `OAuthCliApp`. It will open a browser for user authentication and then process the callback locally. Remember to replace placeholder URLs and client IDs with your actual provider details, ideally via environment variables, for a successful authentication.

import os from oauth_cli_kit import OAuthCliApp def main(): # Replace these placeholders with your actual OAuth provider details or set as environment variables. client_id = os.environ.get("OAUTH_CLI_KIT_CLIENT_ID", "YOUR_CLIENT_ID_HERE") auth_url = os.environ.get("OAUTH_CLI_KIT_AUTH_URL", "https://example.com/oauth/authorize") token_url = os.environ.get("OAUTH_CLI_KIT_TOKEN_URL", "https://example.com/oauth/token") redirect_uri = os.environ.get("OAUTH_CLI_KIT_REDIRECT_URI", "http://localhost:8000") scope = os.environ.get("OAUTH_CLI_KIT_SCOPE", "profile email openid") if client_id == "YOUR_CLIENT_ID_HERE" or auth_url == "https://example.com/oauth/authorize": print("WARNING: Using placeholder OAuth credentials. ") print("Please configure OAUTH_CLI_KIT_CLIENT_ID, OAUTH_CLI_KIT_AUTH_URL, ") print("OAUTH_CLI_KIT_TOKEN_URL environment variables or replace placeholders in the code ") print("with your actual OAuth provider details to run a successful flow.") print(f" Attempting with: Client ID={client_id}, Auth URL={auth_url}, Token URL={token_url}") print("Initiating OAuth 2.0 PKCE flow...") try: oauth_app = OAuthCliApp( client_id=client_id, auth_url=auth_url, token_url=token_url, redirect_uri=redirect_uri, scope=scope, ) token_response = oauth_app.run_flow() # This call opens browser and waits print("\n--- OAuth Flow Successful ---") print(f"Access Token: {token_response.access_token[:10]}... (truncated)") if token_response.refresh_token: print(f"Refresh Token: {token_response.refresh_token[:10]}... (truncated)") print(f"Token Type: {token_response.token_type}") print(f"Expires In: {token_response.expires_in} seconds") if token_response.id_token: print(f"ID Token (JWT): {token_response.id_token[:10]}... (truncated)") except Exception as e: print(f"\n--- OAuth Flow Failed ---") print(f"Error: {e}") print("Please check your configuration, network connection, and browser interaction.") if __name__ == "__main__": main()
oauth-cli-kit --version
Debug
Known issues
breakingAs a 0.x.x version library, the API is not yet stable. Expect potential breaking changes in minor releases as the library evolves.
fix
Review the GitHub repository's changelog or releases notes before upgrading, especially when moving between minor versions (e.g., 0.1.x to 0.2.x).
affects: <1.0.0
gotchaThe library automatically starts a temporary local HTTP server to handle the OAuth redirect URI (e.g., `http://localhost:8000`). Ensure this URI is registered with your OAuth provider and is accessible on the client machine.
fix
Verify that your OAuth provider's registered redirect URI exactly matches the `redirect_uri` you pass to `OAuthCliApp` and that no firewall or other process is blocking port 8000 (or your chosen custom port).
affects: All
gotchaBy default, the library implements the Authorization Code Grant flow with PKCE. Confirm that your OAuth 2.0 provider supports PKCE, as some older or less standard implementations might not.
fix
Consult your OAuth provider's documentation. If PKCE is not supported, you might need to use a different library or a different flow entirely, as this library is strongly oriented towards PKCE.
affects: All
gotchaThe `oauth-cli-kit` only facilitates obtaining access and refresh tokens. It does not handle the secure storage, retrieval, or refreshing of these tokens. This must be implemented by your application.
fix
Implement a secure token storage mechanism (e.g., keyring, encrypted file) and a token refreshing strategy using the obtained refresh token within your CLI application.
affects: All
Upgrade
Version history
0.1.3latest on PyPI · released Feb 13, 2026
Audit
Dependencies
httpxrequiredHTTP client for making requests to OAuth endpoints (authorization, token exchange).
python-pkcerequiredProvides cryptographic helpers for PKCE (Proof Key for Code Exchange).
typerrequiredUsed for building the command-line interface around the OAuth flow (a core intended use case).
richrequiredEnhances console output with rich formatting for a better user experience.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources