access

package
v3.35.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package access contains a service to manage Twitch tokens and scopes

Index

Constants

This section is empty.

Variables

View Source
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

type ClientConfig struct {
	TwitchClient       string
	TwitchClientSecret string

	TokenUpdateHook func()
}

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 New

func New(db database.Connector) (*Service, error)

New creates a new Service on the given database

func (*Service) CopyDatabase added in v3.20.0

func (*Service) CopyDatabase(src, target *gorm.DB) error

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

func (s Service) GetBotUsername() (botUsername string, err error)

GetBotUsername gets the cached bot username

func (Service) GetChannelPermissions added in v3.2.0

func (s Service) GetChannelPermissions(channel string) ([]string, error)

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

func (s Service) HasAnyPermissionForChannel(channel string, scopes ...string) (bool, error)

HasAnyPermissionForChannel checks whether any of the given scopes are granted for the given channel

func (Service) HasPermissionsForChannel

func (s Service) HasPermissionsForChannel(channel string, scopes ...string) (bool, error)

HasPermissionsForChannel checks whether all of the given scopes are granted for the given channel

func (Service) HasTokensForChannel added in v3.22.0

func (s Service) HasTokensForChannel(channel string) (bool, error)

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

func (s Service) ListPermittedChannels() (out []string, err error)

ListPermittedChannels returns a list of all channels having a token for the channels owner

func (Service) RemoveAllExtendedTwitchCredentials added in v3.7.0

func (s Service) RemoveAllExtendedTwitchCredentials() error

RemoveAllExtendedTwitchCredentials wipes the access database

func (Service) RemoveExendedTwitchCredentials

func (s Service) RemoveExendedTwitchCredentials(channel string) error

RemoveExendedTwitchCredentials wipes the access database for a given channel

func (Service) SetBotUsername added in v3.5.0

func (s Service) SetBotUsername(channel string) (err error)

SetBotUsername stores the username of the bot

func (Service) SetExtendedTwitchCredentials

func (s Service) SetExtendedTwitchCredentials(channel, accessToken, refreshToken string, scope []string) (err error)

SetExtendedTwitchCredentials stores tokens and scopes for the given channel into the access database

Jump to

Keyboard shortcuts

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