{"library":"oauth-cli-kit","title":"OAuth CLI Kit","description":"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.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install oauth-cli-kit"],"cli":{"name":"oauth-cli-kit","version":"sh: 1: oauth-cli-kit: not found"}},"imports":["from oauth_cli_kit import OAuthCliApp"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom oauth_cli_kit import OAuthCliApp\n\ndef main():\n    # Replace these placeholders with your actual OAuth provider details or set as environment variables.\n    client_id = os.environ.get(\"OAUTH_CLI_KIT_CLIENT_ID\", \"YOUR_CLIENT_ID_HERE\")\n    auth_url = os.environ.get(\"OAUTH_CLI_KIT_AUTH_URL\", \"https://example.com/oauth/authorize\")\n    token_url = os.environ.get(\"OAUTH_CLI_KIT_TOKEN_URL\", \"https://example.com/oauth/token\")\n    redirect_uri = os.environ.get(\"OAUTH_CLI_KIT_REDIRECT_URI\", \"http://localhost:8000\")\n    scope = os.environ.get(\"OAUTH_CLI_KIT_SCOPE\", \"profile email openid\")\n\n    if client_id == \"YOUR_CLIENT_ID_HERE\" or auth_url == \"https://example.com/oauth/authorize\":\n        print(\"WARNING: Using placeholder OAuth credentials. \")\n        print(\"Please configure OAUTH_CLI_KIT_CLIENT_ID, OAUTH_CLI_KIT_AUTH_URL, \")\n        print(\"OAUTH_CLI_KIT_TOKEN_URL environment variables or replace placeholders in the code \")\n        print(\"with your actual OAuth provider details to run a successful flow.\")\n        print(f\"  Attempting with: Client ID={client_id}, Auth URL={auth_url}, Token URL={token_url}\")\n\n    print(\"Initiating OAuth 2.0 PKCE flow...\")\n\n    try:\n        oauth_app = OAuthCliApp(\n            client_id=client_id,\n            auth_url=auth_url,\n            token_url=token_url,\n            redirect_uri=redirect_uri,\n            scope=scope,\n        )\n        token_response = oauth_app.run_flow() # This call opens browser and waits\n        print(\"\\n--- OAuth Flow Successful ---\")\n        print(f\"Access Token: {token_response.access_token[:10]}... (truncated)\")\n        if token_response.refresh_token:\n            print(f\"Refresh Token: {token_response.refresh_token[:10]}... (truncated)\")\n        print(f\"Token Type: {token_response.token_type}\")\n        print(f\"Expires In: {token_response.expires_in} seconds\")\n        if token_response.id_token:\n            print(f\"ID Token (JWT): {token_response.id_token[:10]}... (truncated)\")\n\n    except Exception as e:\n        print(f\"\\n--- OAuth Flow Failed ---\")\n        print(f\"Error: {e}\")\n        print(\"Please check your configuration, network connection, and browser interaction.\")\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}