-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add some files for grpc auth tutorial #712
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
Conversation
@jonparrott or @waprin |
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not go ahead and use google-auth
:
import google.auth.crypt
import google.auth.jwt
with open(service_account_filename, 'r') as fh:
service_account_info = json.load(fh)
signer = google.auth.crypt.Signer.from_string(
service_account_info['private_key'], service_account_info['private_key_id'])
payload = {
...
}
jwt = google.auth.jwt.encode(signer, payload)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
"""Max lifetime of the token (one hour, in seconds).""" | ||
MAX_TOKEN_LIFETIME_SECS = 3600 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two new lines between constants and function definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks, @qiwzhang! |
api_config_auth.yaml to specify authentication
google_jwt_client.py: to generate JWT token from a service account file.