Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1fc5068

Browse files
committed
improve error message to client
1 parent b57bb70 commit 1fc5068

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

coderd/externalauth/externalauth.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ func (c *Config) RefreshToken(ctx context.Context, db database.Store, externalAu
156156
externalAuthLink.OAuthRefreshToken = ""
157157
}
158158

159+
// Unfortunately have to match exactly on the error message string.
160+
// Improve the error message to account refresh tokens are deleted if
161+
// invalid on our end.
162+
if err.Error() == "oauth2: token expired and refresh token is not set" {
163+
return externalAuthLink, InvalidTokenError("token expired, refreshing is either disabled or refreshing failed and will not be retried")
164+
}
165+
159166
// TokenSource(...).Token() will always return the current token if the token is not expired.
160167
// So this error is only returned if a refresh of the token failed.
161168
return externalAuthLink, InvalidTokenError(fmt.Sprintf("refresh token: %s", err.Error()))

0 commit comments

Comments
 (0)