From 3ac52845835fbcd7e7e9e2879cd35bca7eef1683 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 14 Dec 2023 16:49:33 +0100 Subject: [PATCH] [core] Fix: Properly handle channels without credentials Signed-off-by: Knut Ahlers --- internal/service/access/access.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/service/access/access.go b/internal/service/access/access.go index a92f6c1..f4fe456 100644 --- a/internal/service/access/access.go +++ b/internal/service/access/access.go @@ -172,6 +172,13 @@ func (s Service) GetTwitchClientForChannel(channel string, cfg ClientConfig) (*t return nil, errors.Wrap(err, "decrypting refresh token") } + if perm.AccessToken == "" && perm.RefreshToken == "" { + // We have no tokens but an entry in the permission table: Means + // we still can't do stuff on behalf of that channel so we treat + // that as an unauthorized channel + return nil, ErrChannelNotAuthorized + } + scopes := strings.Split(perm.Scopes, " ") tc := twitch.New(cfg.TwitchClient, cfg.TwitchClientSecret, perm.AccessToken, perm.RefreshToken)