mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-12 00:32:26 +08:00
通过component_verify_ticket 获取 ComponentAccessToken 错误处理 (#521)
This commit is contained in:
@@ -26,6 +26,7 @@ const (
|
|||||||
|
|
||||||
// ComponentAccessToken 第三方平台
|
// ComponentAccessToken 第三方平台
|
||||||
type ComponentAccessToken struct {
|
type ComponentAccessToken struct {
|
||||||
|
util.CommonError
|
||||||
AccessToken string `json:"component_access_token"`
|
AccessToken string `json:"component_access_token"`
|
||||||
ExpiresIn int64 `json:"expires_in"`
|
ExpiresIn int64 `json:"expires_in"`
|
||||||
}
|
}
|
||||||
@@ -57,6 +58,10 @@ func (ctx *Context) SetComponentAccessToken(verifyTicket string) (*ComponentAcce
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if at.ErrCode != 0 {
|
||||||
|
return nil, fmt.Errorf("SetComponentAccessToken Error , errcode=%d , errmsg=%s", at.ErrCode, at.ErrMsg)
|
||||||
|
}
|
||||||
|
|
||||||
accessTokenCacheKey := fmt.Sprintf("component_access_token_%s", ctx.AppID)
|
accessTokenCacheKey := fmt.Sprintf("component_access_token_%s", ctx.AppID)
|
||||||
expires := at.ExpiresIn - 1500
|
expires := at.ExpiresIn - 1500
|
||||||
if err := ctx.Cache.Set(accessTokenCacheKey, at.AccessToken, time.Duration(expires)*time.Second); err != nil {
|
if err := ctx.Cache.Set(accessTokenCacheKey, at.AccessToken, time.Duration(expires)*time.Second); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user