Skip to content

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 a team and silvolu 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

googleapis/google-cloud-python#15222 is it related?

@arithmetic1728
Copy link
Contributor Author

googleapis/google-cloud-python#15222 is it related?

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

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.

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

4 participants