summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-22 11:22:28 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-22 11:22:28 +0200
commitd1d4b8ed524da6bee0cb423ed1fc2fdc943f19ec (patch)
tree7c6e8abb24090677ddc0e8502670d49706e925f2
parentf76e87fa5ec30c416a562c4b29689f6a3e29458c (diff)
API: Only retry authenticated on a 401
-rw-r--r--src/api.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/api.go b/src/api.go
index 6f3d847..93c1c42 100644
--- a/src/api.go
+++ b/src/api.go
@@ -38,8 +38,9 @@ func (server *Server) apiAuthenticatedRetry(method string, endpoint string, opts
if bodyErr != nil {
var error *HTTPStatusError
- if errors.As(bodyErr, &error) {
- GetVPNState().Log(LOG_INFO, fmt.Sprintf("API: Got HTTP error %v, retrying authenticated", bodyErr))
+ // Only retry authenticated if we get a HTTP 401
+ if errors.As(bodyErr, &error) && error.Status == 401 {
+ GetVPNState().Log(LOG_INFO, fmt.Sprintf("API: Got HTTP error %v, retrying authenticated", error))
// Tell the method that the token is expired
server.OAuth.Token.ExpiredTimestamp = GenerateTimeSeconds()
return server.apiAuthenticated(method, endpoint, opts)