auth

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTokens

func ClearTokens() error

ClearTokens removes all stored credentials from keyring and file.

func DetectTokenType

func DetectTokenType(token string) string

DetectTokenType returns "bot" or "user" based on prefix, or "unknown".

func GetBotToken

func GetBotToken() (string, error)

GetBotToken retrieves the stored bot token.

func GetBotUserInfo added in v0.9.3

func GetBotUserInfo() (userID, userName string)

GetBotUserInfo retrieves the stored bot user ID and username.

func GetTeamInfo

func GetTeamInfo() (teamID, teamName string)

GetTeamInfo retrieves the stored team ID and name.

func GetUserInfo

func GetUserInfo() (userID, userName string)

GetUserInfo retrieves the stored human user ID and username.

func GetUserToken

func GetUserToken() (string, error)

GetUserToken retrieves the stored user token.

func IsBotToken

func IsBotToken(token string) bool

IsBotToken returns true if the token looks like a bot token.

func IsUserToken

func IsUserToken(token string) bool

IsUserToken returns true if the token looks like a user token.

func ResolveUserID

func ResolveUserID() (userID, userName string, err error)

ResolveUserID returns the human user's Slack ID, fetching it via auth.test on the user token if not already stored. Only uses the user token (not bot) to ensure the returned ID is the human's, not the bot's.

func StoreBotToken

func StoreBotToken(token string) error

StoreBotToken saves a bot token (xoxb-) to the OS keyring, falling back to plaintext.

func StoreBotUserInfo added in v0.9.3

func StoreBotUserInfo(userID, userName string) error

StoreBotUserInfo saves the bot's Slack user ID and username (from bot token auth.test).

func StoreTeamInfo

func StoreTeamInfo(teamID, teamName string) error

StoreTeamInfo saves the team ID and name.

func StoreUserInfo

func StoreUserInfo(userID, userName string) error

StoreUserInfo saves the human user's Slack ID and username (from user token auth.test).

func StoreUserToken

func StoreUserToken(token string) error

StoreUserToken saves a user token (xoxp-) to the OS keyring, falling back to plaintext.

Types

type TokenInfo

type TokenInfo struct {
	UserID string
	User   string
	TeamID string
	Team   string
	BotID  string
	IsBot  bool
}

TokenInfo holds the result of validating a token via auth.test.

func ValidateToken

func ValidateToken(token string) (*TokenInfo, error)

ValidateToken checks that a token is valid by calling Slack's auth.test.

Jump to

Keyboard shortcuts

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