Skip to content

Commit afa9244

Browse files
committed
Document ADC credential lifetime behavior for importer
Add detailed doc comment to TryGCloudApplicationDefaultCredentialsFile explaining that authorized_user refresh tokens have different lifetimes depending on account type (personal vs managed org), helping users understand when service account keys are the better choice.
1 parent 92a2db0 commit afa9244

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

plugins/gcloud/service_account_key.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ func (e *jsonError) Error() string {
9191

9292
// TryGCloudApplicationDefaultCredentialsFile imports credentials from the
9393
// gcloud application default credentials file at ~/.config/gcloud/application_default_credentials.json.
94+
//
95+
// This file may contain either a service_account key (long-lived, never expires
96+
// unless explicitly deleted) or an authorized_user credential generated by
97+
// "gcloud auth application-default login". Authorized user credentials contain
98+
// a refresh token whose lifetime depends on the Google account type:
99+
//
100+
// - Personal Gmail accounts: refresh tokens are long-lived and only expire
101+
// if revoked, unused for 6 months, or the password is changed.
102+
// - Google Workspace / Cloud Identity accounts: refresh tokens are subject
103+
// to session length policies configured by the org admin (typically 1–24
104+
// hours), after which reauthentication is required.
105+
//
106+
// Both types are imported. Users with managed org accounts should prefer
107+
// service account keys for a more durable credential.
94108
func TryGCloudApplicationDefaultCredentialsFile() sdk.Importer {
95109
return importer.TryFile("~/.config/gcloud/application_default_credentials.json", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) {
96110
var cred gcpCredentialFile

0 commit comments

Comments
 (0)