auth

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package auth provides authentication for Google Cloud APIs.

It supports multiple authentication methods: - Application Default Credentials (for local development via gcloud). - GCP Metadata Server (for GCE, GKE, Cloud Run, Cloud Functions, App Engine).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessToken

func AccessToken(ctx context.Context) (string, error)

AccessToken retrieves a GCP access token. It tries Application Default Credentials first, then falls back to the metadata server. Configuration can be provided via auth.WithConfig in the context.

func ProjectID

func ProjectID(ctx context.Context) (string, error)

ProjectID retrieves the project ID from the GCP metadata server.

func WithConfig added in v0.6.0

func WithConfig(ctx context.Context, cfg *Config) context.Context

WithConfig returns a new context with the given auth config.

Types

type Config added in v0.6.0

type Config struct {
	// MetadataURL is the URL for the GCP metadata server.
	// Defaults to the production metadata server if empty.
	MetadataURL string

	// SkipADC skips Application Default Credentials and goes straight to metadata server.
	// Useful for testing to ensure mock servers are used.
	SkipADC bool
}

Config holds auth configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL