Skip to content

Commit e431d5d

Browse files
Revert "Do not set header X-Goog-User-Project header for the resource google_client_openid_userinfo (#6954)" (#7112) (#5086)
This reverts commit 3411c65d4290095d257b82591c06ee0d63460fa7. Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 8913ac6 commit e431d5d

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

.changelog/7112.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/transport.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ func sendRequestWithTimeout(config *Config, method, project, rawurl, userAgent s
4848
reqHeaders.Set("User-Agent", userAgent)
4949
reqHeaders.Set("Content-Type", "application/json")
5050

51-
if !config.UserProjectOverride {
52-
reqHeaders.Set("X-Goog-User-Project", "")
53-
} else if config.UserProjectOverride && project != "" {
51+
if config.UserProjectOverride && project != "" {
5452
// Pass the project into this fn instead of parsing it from the URL because
5553
// both project names and URLs can have colons in them.
5654
reqHeaders.Set("X-Goog-User-Project", project)

google-beta/utils.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,17 +514,9 @@ func multiEnvSearch(ks []string) string {
514514
}
515515

516516
func GetCurrentUserEmail(config *Config, userAgent string) (string, error) {
517-
// When environment variables UserProjectOverride and BillingProject are set for the provider, the header X-Goog-User-Project is set for the API requests.
518-
// But it causes an error when calling GetCurrentUserEmail. It makes sense to not set header X-Goog-User-Project by setting UserProjectOverride
519-
// to false when calling GetCurrentUserEmail, because it does not create a bill.
520-
origUserProjectOverride := config.UserProjectOverride
521-
config.UserProjectOverride = false
522-
523517
// See https://github.com/golang/oauth2/issues/306 for a recommendation to do this from a Go maintainer
524518
// URL retrieved from https://accounts.google.com/.well-known/openid-configuration
525519
res, err := sendRequest(config, "GET", "", "https://openidconnect.googleapis.com/v1/userinfo", userAgent, nil)
526-
config.UserProjectOverride = origUserProjectOverride
527-
528520
if err != nil {
529521
return "", fmt.Errorf("error retrieving userinfo for your provider credentials. have you enabled the 'https://www.googleapis.com/auth/userinfo.email' scope? error: %s", err)
530522
}

0 commit comments

Comments
 (0)