mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-30 08:31:16 +00:00
[core] Fix: Handle unauthorized error for app-access-tokens
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
08185ced3e
commit
f883bdd1c1
1 changed files with 6 additions and 0 deletions
|
@ -783,6 +783,12 @@ func (c *Client) request(opts clientRequestOpts) error {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if opts.AuthType == authTypeAppAccessToken && resp.StatusCode == http.StatusUnauthorized {
|
||||||
|
// Seems our token was somehow revoked, clear the token and retry which will get a new token
|
||||||
|
c.appAccessToken = ""
|
||||||
|
return errors.New("app-access-token is invalid")
|
||||||
|
}
|
||||||
|
|
||||||
if opts.OKStatus != 0 && resp.StatusCode != opts.OKStatus {
|
if opts.OKStatus != 0 && resp.StatusCode != opts.OKStatus {
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue