Skip to content

Commit 063491c

Browse files
evictpoiana
authored andcommitted
fix(auth/gcp): ensure correct OAuth scope for Artifact Registry with service account
Adjusted OAuth scope to `https://www.googleapis.com/auth/cloud-platform` for compatibility with both service account and Workload Identity setups, resolving invalid scope errors when accessing Artifact Registry. Signed-off-by: Vincent <[email protected]>
1 parent 5846155 commit 063491c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/login/gcp/gcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
// Login checks if passed gcp credentials are correct.
2929
func Login(ctx context.Context, reg string) error {
3030
// Check that we can find a valid token source using GCE or ApplicationDefault.
31-
ts, err := google.DefaultTokenSource(ctx)
31+
ts, err := google.DefaultTokenSource(ctx, "https://www.googleapis.com/auth/cloud-platform")
3232
if err != nil {
3333
return fmt.Errorf("wrong GCP token source, unable to find a valid source: %w", err)
3434
}

pkg/oci/authn/gcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func GCPCredential(ctx context.Context, reg string) (auth.Credential, error) {
5555

5656
// load saved tokenSource or saves it
5757
if SavedTokenSource == nil {
58-
tokenSource, err = google.DefaultTokenSource(ctx)
58+
tokenSource, err = google.DefaultTokenSource(ctx, "https://www.googleapis.com/auth/cloud-platform")
5959
if err != nil {
6060
return auth.EmptyCredential, fmt.Errorf("error while trying to identify a GCP TokenSource %w", err)
6161
}

0 commit comments

Comments
 (0)