Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

fix: add fetch_id_token_credentials - #866

Merged
arithmetic1728 merged 1 commit into
mainfrom
idtoken
Oct 29, 2021
Merged

fix: add fetch_id_token_credentials#866
arithmetic1728 merged 1 commit into
mainfrom
idtoken

Conversation

@arithmetic1728

@arithmetic1728 arithmetic1728 commented Sep 14, 2021

Copy link
Copy Markdown
Contributor

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 a review from a team 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

@busunkim96 busunkim96 left a comment

Copy link
Copy Markdown
Contributor

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

silvolu commented Sep 14, 2021

Copy link
Copy Markdown

+1 for test

@mik-laj

mik-laj commented Sep 14, 2021

Copy link
Copy Markdown
Contributor

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

Comment thread google/oauth2/id_token.py Outdated
Comment thread google/oauth2/id_token.py
Comment thread google/oauth2/id_token.py
@arithmetic1728

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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