Skip to content

Commit

Permalink
fix(auth/gcp): ensure correct OAuth scope for Artifact Registry with …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
evict committed Nov 7, 2024
1 parent c3cd349 commit 84a18c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/login/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// Login checks if passed gcp credentials are correct.
func Login(ctx context.Context, reg string) error {
// Check that we can find a valid token source using GCE or ApplicationDefault.
ts, err := google.DefaultTokenSource(ctx)
ts, err := google.DefaultTokenSource(ctx, "https://www.googleapis.com/auth/cloud-platform")
if err != nil {
return fmt.Errorf("wrong GCP token source, unable to find a valid source: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/oci/authn/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func GCPCredential(ctx context.Context, reg string) (auth.Credential, error) {

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

0 comments on commit 84a18c6

Please sign in to comment.