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.
This commit is contained in:
Mislav Marohnić 2020-08-31 22:22:22 +02:00
parent fd31007075
commit cb4cc72e50

View file

@ -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