8000 Fix encoding issue and comment improvement (#1807) · tritone/python-docs-samples@8b01df8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b01df8

Browse files
joyarzunengelke
authored andcommitted
Fix encoding issue and comment improvement (GoogleCloudPlatform#1807)
Fix the encoding to utf-8 to no receive "JWT validation failed: BAD_FORMAT" message. Also, changes comments to stay alignment with the [Troubleshooting Documentation](https://cloud.google.com/endpoints/docs/openapi/troubleshoot-jwt-openapi)
1 parent 528273f commit 8b01df8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

endpoints/getting-started/clients/google-jwt-client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ def generate_jwt(service_account_file):
4848
# swagger spec. It can be any string.
4949
'aud': 'echo.endpoints.sample.google.com',
5050
# iss must match 'issuer' in the security configuration in your
51-
# swagger spec. It can be any string.
51+
# swagger spec (e.g. service account email). It can be any string.
5252
'iss': 'jwt-client.endpoints.sample.google.com',
5353
# sub and email are mapped to the user id and email respectively.
54-
'sub': '12345678',
54+
# sub should match 'iss'
55+
'sub': 'jwt-client.endpoints.sample.google.com',
5556
'email': 'user@example.com'
5657
}
5758

58-
jwt = google.auth.jwt.encode(signer, payload)
59+
jwt = google.auth.jwt.encode(signer, payload).decode('UTF-8')
5960

6061
return jwt
6162

0 commit comments

Comments
 (0)
0