credentials

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package credentials provides credential retrieval and management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationCredentialsProvider

type ApplicationCredentialsProvider struct {
	// Path to the shared credentials file.
	//
	// If empty will look for "GOOGLE_APPLICATION_CREDENTIALS" env variable. If the
	// env value is empty will default to current user's home directory.
	Filename string
	// contains filtered or unexported fields
}

A ApplicationCredentialsProvider retrieves credentials from the current user's home directory, and keeps track if those credentials are expired.

func (*ApplicationCredentialsProvider) Retrieve

func (p *ApplicationCredentialsProvider) Retrieve() (Value, error)

Retrieve reads and extracts the shared credentials from the current users home directory.

type Credentials

type Credentials struct {
	// contains filtered or unexported fields
}

A Credentials provides synchronous safe retrieval of service account credentials Value.

func NewApplicationCredentials

func NewApplicationCredentials(filename string) *Credentials

NewApplicationCredentials returns a pointer to a new Credentials object wrapping the file provider.

func NewCredentials

func NewCredentials(provider Provider) *Credentials

NewCredentials returns a pointer to a new Credentials with the provider set.

func NewStaticCredentials added in v1.0.0

func NewStaticCredentials(projectID, privateKeyID, privateKey, clientEmail, clientID string) *Credentials

NewStaticCredentials returns a pointer to a new Credentials object wrapping a static credentials value provider.

func (*Credentials) Get

func (c *Credentials) Get() (Value, error)

Get returns the credentials value, or error if the credentials Value failed to be retrieved.

type Provider

type Provider interface {
	// Refresh returns nil if it successfully retrieved the value.
	// Error is returned if the value were not obtainable, or empty.
	Retrieve() (Value, error)
}

A Provider is the interface for any component which will provide credentials Value.

type StaticProvider added in v1.0.0

type StaticProvider struct {
	Value
}

A StaticProvider is a set of credentials which are set pragmatically, and will never expire.

func (*StaticProvider) Retrieve added in v1.0.0

func (s *StaticProvider) Retrieve() (Value, error)

Retrieve returns the credentials or error if the credentials are invalid.

type Value

type Value struct {
	Type                    string `json:"type"`
	ProjectID               string `json:"project_id"`
	PrivateKeyID            string `json:"private_key_id"`
	PrivateKey              string `json:"private_key"`
	ClientEmail             string `json:"client_email"`
	ClientID                string `json:"client_id"`
	AuthURI                 string `json:"auth_uri"`
	TokenURI                string `json:"token_uri"`
	AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`
	ClientX509CertURL       string `json:"client_x509_cert_url"`
}

A Value is the service account credentials value for individual credential fields.

func (*Value) IsValid added in v1.0.0

func (v *Value) IsValid() bool

IsValid ...

Jump to

Keyboard shortcuts

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