auth

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingCredentials = missingCredentialsError{/* contains filtered or unexported fields */}

ErrMissingCredentials can be compared to with Is() to match errors caused by missing or inaccessible credentials.

Functions

func ClientKeyring

func ClientKeyring() (keyring gokeyring.Keyring, err error)

ClientKeyring returns the appropriate keyring (system or file) but does not change the keyring pref.

func InteractiveAuthorizer

func InteractiveAuthorizer(oauthAuthorizeURL string) (code string, err error)

InteractiveAuthorizer prompts the user to log in with their browser and then enter their auth code.

func Login

func Login(user string, allowHTTP bool, keyring gokeyring.Keyring, authorizer Authorizer) error

Login authenticates the user and saves the credentials in the system keychain.

func LoginKeyring

func LoginKeyring(useCleartextFileKeyring bool) (keyring gokeyring.Keyring, err error)

LoginKeyring sets the keyring pref and returns the appropriate keyring (system or file).

func Logout

func Logout(user string) error

func NewGtsTestrigAuthorizer added in v1.1.1

func NewGtsTestrigAuthorizer(t *testing.T) func(oauthAuthorizeURL string) (code string, err error)

NewGtsTestrigAuthorizer returns an authorizer func which logs into a GTS testrig and returns an OOB auth code. This should only be used in tests, but is in the auth package so tests in other packages can load it.

func Switch

func Switch(user string) error

func Whoami

func Whoami() (string, error)

Types

type Authorizer

type Authorizer func(oauthAuthorizeURL string) (code string, err error)

Authorizer is a function that can exchange an OAuth authorization URL for an authorization code.

type Client

type Client struct {
	Client *apiclient.GoToSocialSwaggerDocumentation
	Auth   runtime.ClientAuthInfoWriter
	Flavor flavors.Flavor
	// contains filtered or unexported fields
}

Client is a GtS API client with attached authentication credentials and rate limiter. Credentials may be no-op.

func GtsTestrigClient added in v1.1.1

func GtsTestrigClient(t *testing.T) *Client

GtsTestrigClient returns a client which is logged in to the GTS testrig. TODO: we might want to tear down and restart the testrig for every test, in which case this is inadequate.

func NewAuthClient

func NewAuthClient(user string, keyring gokeyring.Keyring) (*Client, error)

NewAuthClient loads previously stored credentials for the current user, and returns an authorized client instance. If there aren't any credentials, it returns an error.

func (*Client) Wait

func (c *Client) Wait() error

Jump to

Keyboard shortcuts

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