Skip to content

Commit d663339

Browse files
committed
feat: add accessToken get fail log
1 parent 172736b commit d663339

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

common/access-token-store.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package common
33
import (
44
"encoding/json"
55
"fmt"
6+
"io"
67
"net/http"
78
"sync"
89
"time"
@@ -50,11 +51,17 @@ func RefreshAccessToken() {
5051
}
5152
defer responseData.Body.Close()
5253
var res response
53-
err = json.NewDecoder(responseData.Body).Decode(&res)
54+
55+
body, err := io.ReadAll(responseData.Body)
56+
err = json.Unmarshal(body, &res)
5457
if err != nil {
5558
SysError("failed to decode response: " + err.Error())
5659
return
5760
}
61+
if res.AccessToken == "" {
62+
SysError("failed to get access token, response: " + string(body))
63+
return
64+
}
5865
s.Mutex.Lock()
5966
s.AccessToken = res.AccessToken
6067
s.ExpirationSeconds = res.ExpiresIn

0 commit comments

Comments
 (0)