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

Commit 1210361

Browse files
committed
fix jwt encoding bug
1 parent c8ff4e9 commit 1210361

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

samples/api-client/accesstoken_example/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ To run this sample:
106106
--device_id=my-device-id \
107107
--private_key_file=./resources/rsa_private.pem \
108108
--scope=https://www.googleapis.com/auth/cloud-platform \
109-
--algorithm=RS256
109+
--algorithm=RS256 \
110110
generate-access-token
111111
112112
positional arguments:

samples/api-client/accesstoken_example/accesstoken.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
--device_id=my-device-id \\
3131
--private_key_file=./resources/rsa_private.pem \\
3232
--scope=https://www.googleapis.com/auth/cloud-platform \\
33-
--algorithm=RS256
33+
--algorithm=RS256 \\
3434
generate-access-token
3535
"""
3636

@@ -59,7 +59,7 @@ def create_jwt(project_id, algorithm, private_key_file):
5959
encoded_jwt = jwt.encode(
6060
json.loads(jwt_payload), private_key_bytes, algorithm=algorithm
6161
)
62-
return encoded_jwt
62+
return encoded_jwt.decode() if isinstance(encoded_jwt, bytes) else encoded_jwt
6363

6464

6565
def generate_access_token(

0 commit comments

Comments
 (0)