feat: fix issues

This commit is contained in:
Rogee
2025-04-30 15:59:42 +08:00
parent be605ef603
commit af0507d0c1
8 changed files with 60 additions and 21 deletions

View File

@@ -174,6 +174,25 @@ func (a *AuthorizeAccessToken) GetUnionID() string {
return a.Unionid
}
type StableAccessToken struct {
AccessToken string `json:"access_token,omitempty"`
ExpiresIn int64 `json:"expires_in,omitempty"`
}
func (we *Client) GetStableAccessToken() (*StableAccessToken, error) {
params := we.wrapParams(map[string]string{
"grant_type": "client_credential",
})
var data StableAccessToken
_, err := we.client.R().SetSuccessResult(&data).SetBodyJsonMarshal(params).Post("/cgi-bin/stable_token")
if err != nil {
return nil, errors.Wrap(err, "call /cgi-bin/stable_token failed")
}
return &data, nil
}
func (we *Client) AuthorizeCode2Token(code string) (*AuthorizeAccessToken, error) {
params := we.wrapParams(map[string]string{
"code": code,