credentials

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 16 Imported by: 0

README

OAuth2More Credentials

oauth2more/credentials is a package to manage generic OAuth 2.0 credentials definitions.

It works with oauth2more/endpoints to add endpoints for known services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTokenCli

func NewTokenCli(creds Credentials, state string) (token *oauth2.Token, err error)

Types

type ApplicationCredentials

type ApplicationCredentials struct {
	ServerURL       string          `json:"serverURL,omitempty"`
	ApplicationID   string          `json:"applicationID,omitempty"`
	ClientID        string          `json:"clientID,omitempty"`
	ClientSecret    string          `json:"clientSecret,omitempty"`
	OAuth2Endpoint  oauth2.Endpoint `json:"oauth2Endpoint,omitempty"`
	RedirectURL     string          `json:"redirectURL,omitempty"`
	AppName         string          `json:"applicationName,omitempty"`
	AppVersion      string          `json:"applicationVersion,omitempty"`
	OAuthEndpointID string          `json:"oauthEndpointID,omitempty"`
	AccessTokenTTL  int64           `json:"accessTokenTTL,omitempty"`
	RefreshTokenTTL int64           `json:"refreshTokenTTL,omitempty"`
	GrantType       string          `json:"grantType,omitempty"`
}

func (*ApplicationCredentials) AppNameAndVersion

func (ac *ApplicationCredentials) AppNameAndVersion() string

func (*ApplicationCredentials) AuthCodeURL

func (app *ApplicationCredentials) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string

func (*ApplicationCredentials) Config

func (app *ApplicationCredentials) Config() oauth2.Config

func (*ApplicationCredentials) Exchange

func (app *ApplicationCredentials) Exchange(code string) (*oauth2.Token, error)

func (*ApplicationCredentials) InflateURL

func (app *ApplicationCredentials) InflateURL(apiUrlPath string) string

func (*ApplicationCredentials) IsGrantType

func (app *ApplicationCredentials) IsGrantType(grantType string) bool

type Credentials

type Credentials struct {
	Service             string                 `json:"service,omitempty"`
	Subdomain           string                 `json:"subdomain,omitempty"`
	Application         ApplicationCredentials `json:"application,omitempty"`
	PasswordCredentials PasswordCredentials    `json:"passwordCredentials,omitempty"`
	Token               *oauth2.Token          `json:"token,omitempty"`
}

func NewCredentialsJSON added in v0.6.2

func NewCredentialsJSON(data []byte) (Credentials, error)

func NewCredentialsJSONs

func NewCredentialsJSONs(appJson, userJson, accessToken []byte) (Credentials, error)

func ReadCredentialsFromFile

func ReadCredentialsFromFile(credentialsSetFilename, accountKey string, inclAccountsOnError bool) (Credentials, error)

func (*Credentials) Inflate added in v0.6.0

func (creds *Credentials) Inflate() error

func (*Credentials) NewClient

func (creds *Credentials) NewClient() (*http.Client, error)

func (*Credentials) NewClientCli

func (creds *Credentials) NewClientCli(oauth2State string) (*http.Client, error)

func (*Credentials) NewSimpleClient

func (creds *Credentials) NewSimpleClient(httpClient *http.Client) (*httpsimple.SimpleClient, error)

func (*Credentials) NewToken

func (creds *Credentials) NewToken() (*oauth2.Token, error)

func (*Credentials) NewTokenCli

func (creds *Credentials) NewTokenCli(oauth2State string) (*oauth2.Token, error)

NewTokenCli retrieves a token using CLI approach for OAuth 2.0 authorization code or password grant.

type CredentialsSet

type CredentialsSet struct {
	Credentials map[string]Credentials
}

func ReadFileCredentialsSet

func ReadFileCredentialsSet(credentialsSetFilename string, inflateEndpoints bool) (CredentialsSet, error)

func (*CredentialsSet) Accounts

func (set *CredentialsSet) Accounts() []string

func (*CredentialsSet) Get

func (set *CredentialsSet) Get(key string) (Credentials, error)

func (*CredentialsSet) GetClient

func (set *CredentialsSet) GetClient(key string) (*http.Client, error)

func (*CredentialsSet) Inflate added in v0.6.0

func (set *CredentialsSet) Inflate()

func (*CredentialsSet) Keys

func (set *CredentialsSet) Keys() []string

type Options added in v0.7.1

type Options struct {
	CredsPath string `long:"creds" description:"Environment File Path" required:"true"`
	Account   string `long:"account" description:"Environment Variable Name"`
	Token     string `long:"token" description:"Token"`
	CLI       []bool `long:"cli" description:"CLI"`
}

Options is a struct to be used with `github.com/jessevdk/go-flags`. It can be embedded in another struct.

func (*Options) UseCLI added in v0.7.2

func (opts *Options) UseCLI() bool

type PasswordCredentials

type PasswordCredentials struct {
	GrantType            string `url:"grant_type"`
	AccessTokenTTL       int64  `url:"access_token_ttl"`
	RefreshTokenTTL      int64  `url:"refresh_token_ttl"`
	Username             string `json:"username" url:"username"`
	Extension            string `json:"extension" url:"extension"`
	Password             string `json:"password" url:"password"`
	EndpointId           string `url:"endpoint_id"`
	EngageVoiceAccountId int64  `json:"engageVoiceAccountId"`
}

func (*PasswordCredentials) URLValues

func (pw *PasswordCredentials) URLValues() url.Values

func (*PasswordCredentials) UsernameSimple

func (uc *PasswordCredentials) UsernameSimple() string

Jump to

Keyboard shortcuts

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