Documentation ¶
Overview ¶
Package access contains a service to manage Twitch tokens and scopes
Index ¶
- Variables
- type ClientConfig
- type Service
- func (*Service) CopyDatabase(src, target *gorm.DB) error
- func (s Service) GetBotTwitchClient(cfg ClientConfig) (*twitch.Client, error)
- func (s Service) GetBotUsername() (botUsername string, err error)
- func (s Service) GetChannelPermissions(channel string) ([]string, error)
- func (s Service) GetTwitchClientForChannel(channel string, cfg ClientConfig) (*twitch.Client, error)
- func (s Service) HasAnyPermissionForChannel(channel string, scopes ...string) (bool, error)
- func (s Service) HasPermissionsForChannel(channel string, scopes ...string) (bool, error)
- func (s Service) HasTokensForChannel(channel string) (bool, error)
- func (s Service) ListPermittedChannels() (out []string, err error)
- func (s Service) RemoveAllExtendedTwitchCredentials() error
- func (s Service) RemoveExendedTwitchCredentials(channel string) error
- func (s Service) SetBotUsername(channel string) (err error)
- func (s Service) SetExtendedTwitchCredentials(channel, accessToken, refreshToken string, scope []string) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrChannelNotAuthorized = errors.New("channel is not authorized")
ErrChannelNotAuthorized denotes there is no valid authoriztion for the given channel
Functions ¶
This section is empty.
Types ¶
type ClientConfig ¶
ClientConfig contains a configuration to derive new Twitch clients from
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the permission database
func (*Service) CopyDatabase ¶ added in v3.20.0
CopyDatabase enables the bot to migrate the access database
func (Service) GetBotTwitchClient ¶
func (s Service) GetBotTwitchClient(cfg ClientConfig) (*twitch.Client, error)
GetBotTwitchClient returns a twitch.Client configured to act as the bot user
func (Service) GetBotUsername ¶ added in v3.5.0
GetBotUsername gets the cached bot username
func (Service) GetChannelPermissions ¶ added in v3.2.0
GetChannelPermissions returns the scopes granted for the given channel
func (Service) GetTwitchClientForChannel ¶
func (s Service) GetTwitchClientForChannel(channel string, cfg ClientConfig) (*twitch.Client, error)
GetTwitchClientForChannel returns a twitch.Client configured to act as the owner of the given channel
func (Service) HasAnyPermissionForChannel ¶
HasAnyPermissionForChannel checks whether any of the given scopes are granted for the given channel
func (Service) HasPermissionsForChannel ¶
HasPermissionsForChannel checks whether all of the given scopes are granted for the given channel
func (Service) HasTokensForChannel ¶ added in v3.22.0
HasTokensForChannel retrieves and decrypts stored access- and refresh-tokens to evaluate whether tokens are available. Those tokens are NOT validated in this request, it's just checked whether they are present
func (Service) ListPermittedChannels ¶ added in v3.5.1
ListPermittedChannels returns a list of all channels having a token for the channels owner
func (Service) RemoveAllExtendedTwitchCredentials ¶ added in v3.7.0
RemoveAllExtendedTwitchCredentials wipes the access database
func (Service) RemoveExendedTwitchCredentials ¶
RemoveExendedTwitchCredentials wipes the access database for a given channel
func (Service) SetBotUsername ¶ added in v3.5.0
SetBotUsername stores the username of the bot