Allow more HTTP 40x codes to trigger fallback to old OAuth flow

I want to avoid falling back to the old OAuth flow for just any HTTP
4xx/5xx because other statuses should be allowed to surface a problem
with a request or the server.
This commit is contained in:
Mislav Marohnić 2020-08-14 17:31:23 +02:00
parent 60eebd2896
commit a6776d0ba2

View file

@ -57,7 +57,7 @@ func (oa *OAuthFlow) ObtainAccessToken() (accessToken string, err error) {
}
defer resp.Body.Close()
if resp.StatusCode == 404 {
if resp.StatusCode == 401 || resp.StatusCode == 403 || resp.StatusCode == 404 {
// OAuth Device Flow is not available; continue with OAuth browser flow with a
// local server endpoint as callback target
return oa.localServerFlow()