diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-22 11:22:28 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-22 11:22:28 +0200 |
| commit | d1d4b8ed524da6bee0cb423ed1fc2fdc943f19ec (patch) | |
| tree | 7c6e8abb24090677ddc0e8502670d49706e925f2 | |
| parent | f76e87fa5ec30c416a562c4b29689f6a3e29458c (diff) | |
API: Only retry authenticated on a 401
| -rw-r--r-- | src/api.go | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) |
