Skip to content

Commit

Permalink
stable支持
Browse files Browse the repository at this point in the history
  • Loading branch information
paddy committed Mar 26, 2024
1 parent bef83d7 commit fbe9317
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/kernel/accessToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func NewAccessToken(app *ApplicationInterface) (*AccessToken, error) {
InteractsWithCache: NewInteractsWithCache(cacheClient),
}

if config.GetBool("is_stable", false) {
token.RequestMethod = http.MethodPost
}

token.SetCustomToken = nil
token.GetCustomToken = nil
token.OverrideGetEndpoint()
Expand Down
4 changes: 4 additions & 0 deletions src/miniProgram/auth/accessToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func NewAccessToken(app *kernel.ApplicationInterface) (*AccessToken, error) {
token.EndpointToGetToken = "https://api.weixin.qq.com/cgi-bin/token"
token.OverrideGetCredentials()

if (*app).GetConfig().GetBool("is_stable", false) {
token.EndpointToGetToken = "https://api.weixin.qq.com/cgi-bin/stable_token"
}

return token, err
}

Expand Down
4 changes: 4 additions & 0 deletions src/officialAccount/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type UserConfig struct {
Debug bool
NotifyURL string
Sandbox bool

IsStable bool
}

type Http struct {
Expand Down Expand Up @@ -473,6 +475,8 @@ func MapUserConfig(userConfig *UserConfig) (*object.HashMap, error) {
"scopes": userConfig.OAuth.Scopes,
"callbacks": userConfig.OAuth.Callback,
},

"is_stable": userConfig.IsStable,
}

return config, nil
Expand Down
4 changes: 4 additions & 0 deletions src/officialAccount/auth/accessToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func NewAccessToken(app *kernel.ApplicationInterface) (*AccessToken, error) {
token.EndpointToGetToken = "https://api.weixin.qq.com/cgi-bin/token"
token.OverrideGetCredentials()

if (*app).GetConfig().GetBool("is_stable", false) {
token.EndpointToGetToken = "https://api.weixin.qq.com/cgi-bin/stable_token"
}

return token, nil
}

Expand Down

0 comments on commit fbe9317

Please sign in to comment.