Skip to content

Commit

Permalink
Update access token retrieval method
Browse files Browse the repository at this point in the history
  • Loading branch information
royalrick committed Nov 20, 2023
1 parent 50b8d19 commit 5fb84be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions weapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,20 @@ func (cli *Client) AccessToken() (string, error) {
return token, nil
} else {

req := auth.GetAccessTokenRequest{
req := auth.GetStableAccessTokenRequest{
Appid: cli.appid,
Secret: cli.secret,
GrantType: "client_credential",
}
rsp, err := cli.NewAuth().GetAccessToken(&req)
rsp, err := cli.NewAuth().GetStableAccessToken(&req)
if err != nil {
return "", err
}

if err := rsp.GetResponseError(); err != nil {
return "", err
}

cli.cache.Set(key, rsp.AccessToken, time.Duration(rsp.ExpiresIn)*time.Second)
return rsp.AccessToken, nil
}
Expand Down

0 comments on commit 5fb84be

Please sign in to comment.