Skip to content

Commit 6c5e40d

Browse files
committed
more error handling fix
1 parent bc6a2d2 commit 6c5e40d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

internal/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,5 +317,5 @@ type TokenError struct {
317317
}
318318

319319
func (t *TokenError) Error() string {
320-
return fmt.Sprintf("oauth2: error in token fetch repsonse: %s\nerror_description: %s\nerror_uri: %s", t.Err, t.ErrorDescription, t.ErrorURI)
320+
return fmt.Sprintf("oauth2: error in token fetch response: %s\nerror_description: %s\nerror_uri: %s", t.Err, t.ErrorDescription, t.ErrorURI)
321321
}

oauth2.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,14 @@ func (c *Config) Poll(ctx context.Context, da *DeviceAuth, opts ...AuthCodeOptio
272272

273273
errTyp := parseError(err)
274274
switch errTyp {
275-
case errAccessDenied, errExpiredToken:
276-
return tok, errors.New("oauth2: " + errTyp)
277275
case errSlowDown:
278276
interval += 5
279-
fallthrough
280277
case errAuthorizationPending:
278+
// Do nothing.
279+
case errAccessDenied, errExpiredToken:
280+
fallthrough
281+
default:
282+
return tok, err
281283
}
282284
}
283285
}
@@ -329,6 +331,7 @@ func (tf *tokenRefresher) Token() (*Token, error) {
329331
"grant_type": {"refresh_token"},
330332
"refresh_token": {tf.refreshToken},
331333
})
334+
332335
if err != nil {
333336
return nil, err
334337
}

0 commit comments

Comments
 (0)