feat: fix issues
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestClient_AuthorizeUserInfo(t *testing.T) {
|
||||
|
||||
func Test_GetJsTicket(t *testing.T) {
|
||||
Convey("Test GetJsTicket", t, func() {
|
||||
token := ""
|
||||
token := "91_0pKuAiBFquPdLakDyhYqOyNJkGLr7-Egx-IF4bRzw-2Lpm7wxgz6zVBNJ36FvMXmiu8bz9BTtspVICf1zDZ3XWuVLwTq6T3a6WG1k6NHv6E0PadT-G5x2Y85-xUECBcADATRQ"
|
||||
ticket, err := getClient().GetJSTicket(token)
|
||||
So(err, ShouldBeNil)
|
||||
So(ticket, ShouldNotBeEmpty)
|
||||
@@ -95,3 +95,13 @@ func Test_GetJsTicket(t *testing.T) {
|
||||
t.Log("Js Ticket:", ticket)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_GetStableToken(t *testing.T) {
|
||||
Convey("Test_GetStableToken GetJsTicket", t, func() {
|
||||
token, err := getClient().GetStableAccessToken()
|
||||
So(err, ShouldBeNil)
|
||||
So(token, ShouldNotBeNil)
|
||||
|
||||
t.Logf("Stable Token: %+v", token)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user