From cb4cc72e5030d358138f859babde62ab02e7b6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 31 Aug 2020 22:22:22 +0200 Subject: [PATCH] Handle HTTP 422 response to OAuth Device flow detection If HTTP 422 is encountered, assume that OAuth Device Flow is unavailable and fall back to OAuth app authorization flow. --- auth/oauth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/oauth.go b/auth/oauth.go index 3a933811c..a4ccc5a79 100644 --- a/auth/oauth.go +++ b/auth/oauth.go @@ -69,7 +69,7 @@ func (oa *OAuthFlow) ObtainAccessToken() (accessToken string, err error) { } } - if resp.StatusCode == 401 || resp.StatusCode == 403 || resp.StatusCode == 404 || + if resp.StatusCode == 401 || resp.StatusCode == 403 || resp.StatusCode == 404 || resp.StatusCode == 422 || (resp.StatusCode == 400 && values != nil && values.Get("error") == "unauthorized_client") { // OAuth Device Flow is not available; continue with OAuth browser flow with a // local server endpoint as callback target