Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 5 commits into from
Dec 12, 2016

Conversation

qiwzhang
Copy link
Contributor

api_config_auth.yaml to specify authentication
google_jwt_client.py: to generate JWT token from a service account file.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 11, 2016
@qiwzhang
Copy link
Contributor Author

@jonparrott or @waprin
could you help to review it?

@@ -0,0 +1,65 @@
#!/usr/bin/env python
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@theacodes theacodes self-assigned this Dec 12, 2016

"""Max lifetime of the token (one hour, in seconds)."""
MAX_TOKEN_LIFETIME_SECS = 3600

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@theacodes theacodes merged commit a1b5e56 into GoogleCloudPlatform:master Dec 12, 2016
@theacodes
Copy link
Contributor

Thanks, @qiwzhang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.