Skip to content
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

Cannot get id_token when using impersonated service account: #600

Closed
liufuyang opened this issue Oct 21, 2022 · 2 comments
Closed

Cannot get id_token when using impersonated service account: #600

liufuyang opened this issue Oct 21, 2022 · 2 comments

Comments

@liufuyang
Copy link

func main() {
	ctx := context.Background()
	defaultTokenSource, _ := google.DefaultTokenSource(
		ctx,
		"https://www.googleapis.com/auth/cloud-platform",
	)
	token, err := defaultTokenSource.Token()
	idToken, ok := token.Extra("id_token").(string)
	if !ok {
		fmt.Println("No id_token")
	}
	fmt.Println(err)
	fmt.Println(idToken)
}

With a simple piece of code above, if a normal google user authentication is used, one could get
refresh token and also the id_token, seem from the debug screenshot:
image

But when an impersonated service account is used (by setting the key.json via setting GOOGLE_APPLICATION_CREDENTIALS, and the json key is got by running gcloud --impersonate-service-account [email protected] auth application-default login), there is no refresh token got and also no raw and no id_token (a JWT token) on it
image

Resulting in the code above prints no id_token and no JWT token can be retrieved.

Is this expected behaviour? Thanks.

@liufuyang liufuyang changed the title google impersonated service account: Cannot get id_token when using impersonated service account: Nov 14, 2022
@seankhliao
Copy link
Member

I believe the appropriate place is with googleapis/google-api-go-client#873

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2023
@liufuyang
Copy link
Author

@seankhliao May I ask how is this package related to the googleapis/google-api-go-client#1792 change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants