Skip to content

Commit 0a87693

Browse files
CLOUDP-118714 add IsTimeoutErr func (#291)
1 parent 33f2542 commit 0a87693

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

auth/device_flow.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
atlas "go.mongodb.org/atlas/mongodbatlas"
2626
)
2727

28+
const authExpiredError = "DEVICE_AUTHORIZATION_EXPIRED"
29+
2830
// DeviceCode holds information about the authorization-in-progress.
2931
type DeviceCode struct {
3032
UserCode string `json:"user_code"` // UserCode is the code presented to users
@@ -146,3 +148,8 @@ func (c Config) RevokeToken(ctx context.Context, token, tokenTypeHint string) (*
146148

147149
return c.Do(ctx, req, nil)
148150
}
151+
152+
func IsTimeoutErr(err error) bool {
153+
var target *atlas.ErrorResponse
154+
return errors.Is(err, ErrTimeout) || (errors.As(err, &target) && target.ErrorCode == authExpiredError)
155+
}

0 commit comments

Comments
 (0)