Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: add fetch_id_token_credentials #866

Merged
merged 1 commit into from
Oct 29, 2021
Merged

fix: add fetch_id_token_credentials #866

merged 1 commit into from
Oct 29, 2021

Conversation

arithmetic1728
Copy link
Contributor

@arithmetic1728 arithmetic1728 commented Sep 14, 2021

fix: #865

fetch_id_token creates a credentials, refresh it, then return the token. In this PR, we refactor the credentials creation part in fetch_id_token method to a new fetch_id_token_credentials method.

Note that we only support service account credentials and compute engine credentials, not user credentials.

The usage is:

request = google.auth.transport.requests.Request()
target_audience = "https://pubsub.googleapis.com"

credentials = google.oauth2.id_token.fetch_id_token_credentials(request, target_audience)

# Refresh the credential to obtain an ID token.
credentials.refresh(request)
id_token = credentials.token
id_token_expiry = credentials.expiry

@arithmetic1728 arithmetic1728 requested review from silvolu and a team as code owners September 14, 2021 01:27
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 14, 2021
Copy link
Contributor

@busunkim96 busunkim96 left a comment

Choose a reason for hiding this comment

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

LGTM. Could a test be added for the new function?

@silvolu
Copy link

silvolu commented Sep 14, 2021

+1 for test

@mik-laj
Copy link
Contributor

mik-laj commented Sep 14, 2021

#590 is it related?

google/oauth2/id_token.py Outdated Show resolved Hide resolved
@arithmetic1728
Copy link
Contributor Author

#590 is it related?

It resolves 590 partially (it doesn't support user credential)

# for free to join this conversation on GitHub. Already have an account? # 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.

In fetch_id_token(), return token's expiry along with the token
4 participants