auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 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. In test mode, ADC is skipped to ensure mock servers are used.

func ProjectID

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

ProjectID retrieves the project ID from the GCP metadata server.

func SetMetadataURL

func SetMetadataURL(urlStr string) func()

SetMetadataURL sets a custom metadata server URL for testing. Returns a function that restores the original URL. WARNING: This function should only be called in test code. Set DS9_ALLOW_TEST_OVERRIDES=true to enable in non-test environments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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