auth

package
v0.0.0-...-6d0359b Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const CREDENTIAL_KEY = "credentials"

Variables

View Source
var (
	ErrCredentialsNotFound      = errors.New("credentials not found")
	ErrInvalidCredentialsStored = errors.New("invalid credentials stored")
	ErrInvalidCredentialsFields = errors.New("invalid credentials fields")
)
View Source
var (
	ErrRequiredEnvEmpty = errors.New("required env empty")
	ErrStatusNotOk      = errors.New("status not ok")
)

Functions

func CalcExpirationRemaining

func CalcExpirationRemaining(cred *ApiCredentials) time.Duration

func SaveCredentials

func SaveCredentials(cred *ApiCredentials) (err error)

Types

type ApiCredentials

type ApiCredentials struct {
	ExpiresIn    int       `json:"expires_in"`
	RefreshedAt  time.Time `json:"refreshed_at"`
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
}

func GetCredentialsCache

func GetCredentialsCache() (cred *ApiCredentials, err error)

func GetToken

func GetToken() (cred *ApiCredentials, err error)

func LoadCredentials

func LoadCredentials() (cred *ApiCredentials, err error)

func RefreshToken

func RefreshToken() (cred *ApiCredentials, err error)

func (*ApiCredentials) IsValid

func (cred *ApiCredentials) IsValid() bool

func (*ApiCredentials) SaveCache

func (cred *ApiCredentials) SaveCache()

Jump to

Keyboard shortcuts

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