Skip to content

examples/oauth_pkce_example.py is broken: it imports OAuth PKCE helpers that were deleted in e6b0242 #583

Description

@rajarshidattapy

Summary

The repository's only example, examples/oauth_pkce_example.py, fails immediately on
import. The four OAuth PKCE helpers it uses were removed from the package in April 2026,
but the example was left behind.

Steps to reproduce

uv sync
uv run python examples/oauth_pkce_example.py

Actual behavior

Traceback (most recent call last):
  File "examples/oauth_pkce_example.py", line 10, in <module>
    from openrouter.utils import (
    ...<4 lines>...
    )
ImportError: cannot import name 'oauth_create_sha256_code_challenge' from 'openrouter.utils'

All four imported symbols are gone — grep -rn across src/ returns zero hits for each:

  • oauth_create_sha256_code_challenge
  • oauth_create_authorization_url
  • CreateSHA256CodeChallengeRequest
  • CreateAuthorizationUrlRequestWithPKCE

History

  • 05f81a5 "add oauth helpers" (2025-11-13) added src/openrouter/utils/oauth_create_sha256_code_challenge.py
    (120 lines) and src/openrouter/utils/oauth_create_authorization_url.py (95 lines), wired
    their exports into src/openrouter/utils/__init__.py, and added this example.
  • e6b0242 "chore: clean up removed docs and update generated SDK files" (2026-04-02)
    deleted both helper modules and their utils/__init__.py exports as part of a broad
    regeneration. It touched no files under examples/, so the example has been dead on
    main for roughly four months.

Root cause, and why a straight revert will not hold

Both helpers were hand-written files placed inside src/openrouter/utils/, which is
otherwise entirely Speakeasy-generated. .genignore currently protects only:

pylintrc
docs/docs.json
docs/overview.mdx

Nothing there covers src/openrouter/utils/oauth_*.py, so the next regeneration was always
going to remove them — which is exactly what e6b0242 did. Restoring the files without
also adding them to .genignore would reintroduce the same silent deletion.

Suggested fix

Either direction resolves the broken example; the choice is whether the helpers are meant
to be part of the SDK:

  1. Drop the example. If the helpers were deliberately cut, delete
    examples/oauth_pkce_example.py (and the now-empty examples/ directory). Smallest
    change, and it stops shipping code that cannot run.
  2. Restore the helpers. Bring back both modules and their utils/__init__.py exports,
    and add them to .genignore so regeneration cannot wipe them again.

Worth noting for anyone hitting this in the meantime: the OAuth flow itself is not broken.
client.o_auth.create_auth_code and client.o_auth.exchange_auth_code_for_api_key are
both still present and generated. Only the client-side code-verifier/challenge generation
is missing, and that is a few lines of secrets + hashlib + base64 from the standard
library.

Environment

  • openrouter 1.1.23 (main @ cb401a8)
  • Python 3.11.9, httpx 0.28.1, pydantic 2.12.4
  • Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions