diff options
Diffstat (limited to 'client/go/auth/token.go')
-rw-r--r-- | client/go/auth/token.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/client/go/auth/token.go b/client/go/auth/token.go index b7bf5d76042..d6f5e6dfa43 100644 --- a/client/go/auth/token.go +++ b/client/go/auth/token.go @@ -10,6 +10,7 @@ import ( "io" "net/http" "net/url" + "strings" ) type TokenResponse struct { @@ -54,8 +55,13 @@ func (t *TokenRetriever) Refresh(ctx context.Context, system string) (TokenRespo defer r.Body.Close() if r.StatusCode != http.StatusOK { b, _ := io.ReadAll(r.Body) - bodyStr := string(b) - return TokenResponse{}, fmt.Errorf("cannot get a new access token from the refresh token: %s", bodyStr) + res := struct { + Description string `json:"error_description"` + }{} + if json.Unmarshal(b, &res) == nil { + return TokenResponse{}, errors.New(strings.ToLower(strings.TrimSuffix(res.Description, "."))) + } + return TokenResponse{}, fmt.Errorf("cannot get a new access token from the refresh token: %s", string(b)) } var res TokenResponse |