Home / Function/ load_auth() — anthropic-sdk-python Function Reference

load_auth() — anthropic-sdk-python Function Reference

Architecture documentation for the load_auth() function in _auth.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  064fa540_38f9_e315_bc1b_8783d8a1458a["load_auth()"]
  5fc3941b_5c44_ade1_4cda_60070b8f7508["_auth.py"]
  064fa540_38f9_e315_bc1b_8783d8a1458a -->|defined in| 5fc3941b_5c44_ade1_4cda_60070b8f7508
  26ddfdd3_edf1_2adc_5603_1eed5c624138["_ensure_access_token()"]
  26ddfdd3_edf1_2adc_5603_1eed5c624138 -->|calls| 064fa540_38f9_e315_bc1b_8783d8a1458a
  style 064fa540_38f9_e315_bc1b_8783d8a1458a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/lib/vertex/_auth.py lines 18–41

def load_auth(*, project_id: str | None) -> tuple[Credentials, str]:
    try:
        from google.auth.transport.requests import Request  # type: ignore[import-untyped]
    except ModuleNotFoundError as err:
        raise RuntimeError(
            f"Could not import google.auth, you need to install the SDK with `pip install anthropic[vertex]`"
        ) from err

    credentials, loaded_project_id = google_auth.default(
        scopes=["https://www.googleapis.com/auth/cloud-platform"],
    )
    credentials = cast(Any, credentials)
    credentials.refresh(Request())

    if not project_id:
        project_id = loaded_project_id

    if not project_id:
        raise ValueError("Could not resolve project_id")

    if not isinstance(project_id, str):
        raise TypeError(f"Expected project_id to be a str but got {type(project_id)}")

    return credentials, project_id

Subdomains

Frequently Asked Questions

What does load_auth() do?
load_auth() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/vertex/_auth.py.
Where is load_auth() defined?
load_auth() is defined in src/anthropic/lib/vertex/_auth.py at line 18.
What calls load_auth()?
load_auth() is called by 1 function(s): _ensure_access_token.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free