googleapis/mcp-toolbox · error

failed to find default Google Cloud credentials with scope %

Error message

failed to find default Google Cloud credentials with scope %q: %w

What it means

Error "failed to find default Google Cloud credentials with scope %q: %w" thrown in googleapis/mcp-toolbox.

Source

Thrown at internal/sources/cloudhealthcare/cloud_healthcare.go:179

	}
	ts := oauth2.StaticTokenSource(token)

	// Initialize the Healthcare service with tokenSource
	service, err := healthcare.NewService(ctx, option.WithUserAgent(userAgent), option.WithTokenSource(ts))
	if err != nil {
		return nil, fmt.Errorf("failed to create Healthcare service: %w", err)
	}
	service.UserAgent = userAgent
	return service, nil
}

func initHealthcareConnection(ctx context.Context, tracer trace.Tracer, name string) (*healthcare.Service, oauth2.TokenSource, error) {
	ctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)
	defer span.End()

	cred, err := google.FindDefaultCredentials(ctx, healthcare.CloudHealthcareScope)
	if err != nil {
		return nil, nil, fmt.Errorf("failed to find default Google Cloud credentials with scope %q: %w", healthcare.CloudHealthcareScope, err)
	}

	userAgent, err := util.UserAgentFromContext(ctx)
	if err != nil {
		return nil, nil, err
	}

	service, err := healthcare.NewService(ctx, option.WithUserAgent(userAgent), option.WithCredentials(cred))
	if err != nil {
		return nil, nil, fmt.Errorf("failed to create Healthcare service: %w", err)
	}
	service.UserAgent = userAgent
	return service, cred.TokenSource, nil
}

var _ sources.Source = &Source{}

type Source struct {

View on GitHub (pinned to 8cc6e09de2)

When it happens

Trigger: Thrown at internal/sources/cloudhealthcare/cloud_healthcare.go:179 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/4cc9349890cfbd2e. Report an issue: GitHub.