cookie

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(client *http.Client, base *url.URL, conf Config) error

Login makes a login request using the supplied HTTP client and Config to the supplied base. The HTTP client must have a cookie jar attached, like what is provided by New.

func New

func New(conf Config, base *url.URL) (*http.Client, error)

New returns an HTTP client configured to use the provided Config and base URL. If base is provided, the client will log in automatically and will be usable upon return (or will return an auth error). If base is nil, the client will not authenticate. This is useful

func SetSession

func SetSession(client *http.Client, sessionID string, baseURL *url.URL) error

SetSession sets an existing adama_session cookie to a given client. This is useful for apps where the consumer arrives with a session already intact (such as apps).

Types

type Config

type Config struct {
	Username string
	Password string
	APIKey   string
}

Config represents a configuration for cookie authentication. It should be directly instantiated with the username, password, and API key for authentication.

func GetCredentialsFromEnv

func GetCredentialsFromEnv() Config

GetCredentialsFromEnv constructs a new Config object from the environment. It expecs the following environment variables: T1_API_USERNAME, T1_API_PASSWORD, T1_API_KEY

func (Config) Encode

func (c Config) Encode() url.Values

Encode constructs a url.Values object from a Config object

Jump to

Keyboard shortcuts

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