{"library":"oic","title":"pyoidc (OpenID Connect and OAuth2 Library)","description":"pyoidc is a Python implementation of both the OAuth2 authorization framework and the OpenID Connect (OIDC) authentication layer on top of it. It provides tools for building OIDC Clients (Relying Parties) and OIDC Providers (OpenID Providers). The current version is 1.7.0, and it maintains an active release cadence with updates typically every few months, addressing bug fixes, dependency updates, and Python version compatibility.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install oic"],"cli":null},"imports":["from oic.oic.client import Client","from oic.oic.server import Provider","from oic.utils.keyio import KeyJar","from oic.oic.message import AuthorizationRequest"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom oic.oic.client import Client\nfrom oic.utils.keyio import KeyJar\n\n# Configure these environment variables for a real flow\nISSUER = os.environ.get(\"OIDC_ISSUER\", \"https://accounts.google.com\")\nCLIENT_ID = os.environ.get(\"OIDC_CLIENT_ID\", \"your_client_id_here\")\nCLIENT_SECRET = os.environ.get(\"OIDC_CLIENT_SECRET\", \"your_client_secret_here\")\nREDIRECT_URI = os.environ.get(\"OIDC_REDIRECT_URI\", \"http://localhost:8080/cb\")\n\n# 1. Initialize the OIDC Client\n# A KeyJar is essential for managing cryptographic keys (e.g., for JWTs)\nkeyjar = KeyJar()\nclient = Client(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, keyjar=keyjar)\n\nprint(f\"Initialized OIDC Client for issuer: {ISSUER}\")\n\ntry:\n    # 2. Discover the OIDC Provider's configuration\n    # This fetches endpoints, supported algorithms, etc., from the issuer.\n    client.provider_config(ISSUER)\n    print(f\"Discovered OIDC Provider config for {ISSUER}\")\n    print(f\"Authorization endpoint: {client.authorization_endpoint}\")\n\n    # 3. Construct an Authorization Request\n    # This generates the URL to which the user's browser should be redirected.\n    auth_req = client.construct_AuthorizationRequest(\n        request_args={\n            \"scope\": [\"openid\", \"profile\", \"email\"], # Request standard OIDC scopes\n            \"redirect_uri\": REDIRECT_URI,\n            \"response_type\": [\"code\"], # Request an authorization code\n            \"state\": \"some_random_state_string\", # CSRF protection\n            \"nonce\": \"another_random_nonce_string\", # Replay attack protection for ID Tokens\n        }\n    )\n\n    login_url = auth_req.request(client.authorization_endpoint)\n    print(f\"\\nUser should be redirected to:\\n{login_url}\")\n    print(\"\\nAfter user authenticates, they will be redirected back to `REDIRECT_URI`\")\n    print(\"with `code`, `state` (and potentially `id_token`, `access_token`) parameters.\")\n    print(\"Further steps involve handling this redirect and exchanging the code for tokens.\")\n\nexcept Exception as e:\n    print(f\"An error occurred during client setup or discovery: {e}\")\n    print(\"Ensure `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` are correctly configured.\")\n    print(\"For a full OIDC flow, a web server is required to handle redirects.\")","lang":"python","description":"This quickstart demonstrates the initial steps of setting up an OIDC Relying Party (client) using `oic`: client initialization, provider discovery, and generating the authorization request URL. For a full authentication flow, a web server is required to handle the redirect URI and process the authorization code exchange.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"1.7.0","pypi_latest":"1.7.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":6.1,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"63.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":6.9,"import_time_s":null,"mem_mb":null,"disk_size":"64M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"69.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.9,"import_time_s":null,"mem_mb":null,"disk_size":"70M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"60.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.9,"import_time_s":null,"mem_mb":null,"disk_size":"60M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"60.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.1,"import_time_s":null,"mem_mb":null,"disk_size":"60M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"63.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"oic","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":7.8,"import_time_s":null,"mem_mb":null,"disk_size":"64M"}]}}