Skip to content

Commit c793b1c

Browse files
committed
fix(oauth2): cast id_token to string for mypy
1 parent def353c commit c793b1c

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ ignore_missing_imports = True
5757
[mypy-grpc_status]
5858
ignore_missing_imports = True
5959

60+
[mypy-jwt,jwt.*]
61+
ignore_missing_imports = True
62+
6063
[mypy-ibis.*]
6164
ignore_missing_imports = True
6265

packages/google-auth/google/oauth2/id_token.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ def verify_token(
132132
Returns:
133133
Mapping[str, Any]: The decoded token.
134134
"""
135+
if isinstance(id_token, bytes):
136+
id_token = id_token.decode("utf-8")
137+
135138
certs = _fetch_certs(request, certs_url)
136139

137140
if "keys" in certs:
138141
try:
139-
import jwt as jwt_lib # type: ignore
140-
from jwt.api_jwk import PyJWKSet # type: ignore
142+
import jwt as jwt_lib
143+
from jwt.api_jwk import PyJWKSet
141144
except ImportError as caught_exc: # pragma: NO COVER
142145
raise ImportError(
143146
"The pyjwt library is not installed, please install the pyjwt package to use the jwk certs format."

0 commit comments

Comments
 (0)