Documentation
¶
Overview ¶
Package credential manages Slack credentials for slagent.
Index ¶
- func Dir() string
- func Ensure(workspace string, extractFn func() error) error
- func IsAuthError(err error) bool
- func ListWorkspaces() (names []string, defaultName string, err error)
- func Path() string
- func Save(name string, creds *Credentials) error
- func SetDefault(name string) error
- type Credentials
- type Result
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ensure ¶
Ensure loads credentials for the workspace. If none exist, it calls extractFn to obtain them (e.g. interactive auth). Returns an error if credentials are still unavailable after extraction.
func IsAuthError ¶
IsAuthError returns true if the error is a Slack authentication failure (expired, revoked, or invalid token).
func ListWorkspaces ¶
ListWorkspaces returns all workspace names sorted, with the default first.
func Save ¶
func Save(name string, creds *Credentials) error
Save writes credentials for a workspace. Does not change the default.
Types ¶
type Credentials ¶
type Credentials struct {
Token string `json:"token,omitempty"`
Type string `json:"type,omitempty"` // "bot", "user", or "session"
Cookie string `json:"cookie,omitempty"` // xoxd-... for xoxc session tokens
Enterprise bool `json:"enterprise,omitempty"` // true for enterprise grid workspaces
}
Credentials holds the stored Slack token for one workspace.
func Load ¶
func Load(workspace string) (*Credentials, error)
Load reads stored credentials. Empty workspace uses the default.
func (*Credentials) EffectiveToken ¶
func (c *Credentials) EffectiveToken() string
EffectiveToken returns the token.
func (*Credentials) EffectiveType ¶
func (c *Credentials) EffectiveType() string
EffectiveType returns the token type, inferring from prefix if not set.