auth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRootCmd

func GetRootCmd() *cobra.Command

func TokenSource

func TokenSource() oauth2.TokenSource

TokenSource returns a cached application default credentials or falls back to the compute token source

func WriteApplicationDefaultCredentials

func WriteApplicationDefaultCredentials(adc *ApplicationDefaultCredentials) error

WriteApplicationDefaultCredentials idempotently writes out the application default credentials to disk

Types

type ApplicationDefaultCredentials

type ApplicationDefaultCredentials struct {
	ClientID          string    `json:"client_id,omitempty"`
	ClientSecret      string    `json:"client_secret,omitempty"`
	QuotaProjectId    string    `json:"quota_project_id,omitempty"`
	AccessToken       string    `json:"access_token,omitempty"`
	AccessTokenExpiry time.Time `json:"access_token_expiry,omitempty"`
	RefreshToken      string    `json:"refresh_token,omitempty"`
	Type              string    `json:"type,omitempty"`
	AuthUri           string    `json:"auth_uri,omitempty"`
	TokenUri          string    `json:"token_uri,omitempty"`

	// service account fields
	ProjectID               string `json:"project_id,omitempty"`
	PrivateKeyID            string `json:"private_key_id,omitempty"`
	PrivateKey              string `json:"private_key,omitempty"`
	ClientEmail             string `json:"client_email,omitempty"`
	AuthProviderX509CertUrl string `json:"auth_provider_x509_cert_url,omitempty"`
	ClientX509CertUrl       string `json:"client_x509_cert_url,omitempty"`
	// contains filtered or unexported fields
}

ApplicationDefaultCredentials is the a struct representing the application_default_credentials.json format. We add access_token and access_token_expiry for easy token caching and refresh.

func ReadApplicationDefaultCredentials

func ReadApplicationDefaultCredentials() (*ApplicationDefaultCredentials, error)

func (*ApplicationDefaultCredentials) SetContext

func (a *ApplicationDefaultCredentials) SetContext(ctx context.Context)

SetContext allows you to set the context on token refresh operations

func (*ApplicationDefaultCredentials) Token

Token ensures that we cache the access token

Jump to

Keyboard shortcuts

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