Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types to verify_token and Request __init__ based on comments in the source code. #1588

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/auth/transport/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Request(transport.Request):
.. automethod:: __call__
"""

def __init__(self, session=None):
def __init__(self, session: requests.Session | None = None) -> None:
if not session:
session = requests.Session()

Expand Down
15 changes: 9 additions & 6 deletions google/oauth2/id_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
from google.auth import environment_vars
from google.auth import exceptions
from google.auth import jwt
from google.auth import transport

from typing import Any, Mapping, Union


# The URL that provides public certificates for verifying ID tokens issued
Expand Down Expand Up @@ -104,12 +107,12 @@ def _fetch_certs(request, certs_url):


def verify_token(
id_token,
request,
audience=None,
certs_url=_GOOGLE_OAUTH2_CERTS_URL,
clock_skew_in_seconds=0,
):
id_token: Union[str, bytes],
request: transport.Request,
audience: str | list[str] | None = None,
certs_url: str = _GOOGLE_OAUTH2_CERTS_URL,
clock_skew_in_seconds: int = 0,
) -> Mapping[str, Any]:
"""Verifies an ID token and returns the decoded token.

Args:
Expand Down