Documentation
¶
Overview ¶
Package creds is ~/.atmee/credentials.json: the saved Avatar API key, or the session of a user who signed in with the browser. It holds one or the other; saving either replaces the file.
Index ¶
Constants ¶
const ( DefaultHomeEnv = "ATMEE_HOME" DefaultKeyEnv = "ATMEE_API_KEY" )
The environment variables of the default store: the folder that replaces ~/.atmee, and an API key.
Variables ¶
This section is empty.
Functions ¶
func WriteSecretFile ¶
WriteSecretFile writes b to path whole: a fresh file at mode 600 renamed into place, so a secret is never readable by others (even over an older, wider file) and a reader never sees half of it.
Types ¶
type Session ¶
type Session struct {
BaseURL string `json:"base_url"`
TokenEndpoint string `json:"token_endpoint"`
ClientID string `json:"client_id"`
// Resource is the protected resource the tokens are bound to (RFC 8707);
// a refresh names it again.
Resource string `json:"resource,omitempty"`
AccessToken string `json:"access_token"`
// RefreshToken is empty when the server issued none: the sign-in then
// lasts as long as its access token.
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresAt time.Time `json:"expires_at"`
Email string `json:"email,omitempty"`
// AccountID is sent as X-Account-Id: which account a user of several
// acts for. Empty for a user of one account.
AccountID string `json:"account_id,omitempty"`
}
Session is a browser sign-in: the user's OAuth tokens and what refreshing them needs. BaseURL is the Avatar API it was made for; the tokens come from that deployment's sign-in and are useless anywhere else.
type Store ¶
Store is one credentials file. KeyEnv names the variable whose key wins over the file (DefaultKeyEnv when empty).
func In ¶
In is the store in the folder of that name under the home directory (homeEnv overrides), with its API key read from keyEnv. Each variant passes its own variables, so one never reads another's saved key.
func (Store) SaveAPIKey ¶
SaveAPIKey writes the key, dropping a saved sign-in.
func (Store) SaveSession ¶
SaveSession writes the sign-in, dropping a saved key.