Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
fix jwt encoding bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gcseh committed Sep 16, 2021
1 parent c8ff4e9 commit 1210361
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples/api-client/accesstoken_example/README.rst
Expand Up @@ -106,7 +106,7 @@ To run this sample:
--device_id=my-device-id \
--private_key_file=./resources/rsa_private.pem \
--scope=https://www.googleapis.com/auth/cloud-platform \
--algorithm=RS256
--algorithm=RS256 \
generate-access-token
positional arguments:
Expand Down
4 changes: 2 additions & 2 deletions samples/api-client/accesstoken_example/accesstoken.py
Expand Up @@ -30,7 +30,7 @@
--device_id=my-device-id \\
--private_key_file=./resources/rsa_private.pem \\
--scope=https://www.googleapis.com/auth/cloud-platform \\
--algorithm=RS256
--algorithm=RS256 \\
generate-access-token
"""

Expand Down Expand Up @@ -59,7 +59,7 @@ def create_jwt(project_id, algorithm, private_key_file):
encoded_jwt = jwt.encode(
json.loads(jwt_payload), private_key_bytes, algorithm=algorithm
)
return encoded_jwt
return encoded_jwt.decode() if isinstance(encoded_jwt, bytes) else encoded_jwt


def generate_access_token(
Expand Down

0 comments on commit 1210361

Please sign in to comment.