1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00

通过component_verify_ticket 获取 ComponentAccessToken 错误处理 (#521)

This commit is contained in:
zxr615
2022-01-05 09:13:25 +08:00
committed by GitHub
parent 2f898f80f6
commit 172c4abde5

View File

@@ -26,6 +26,7 @@ const (
// ComponentAccessToken 第三方平台
type ComponentAccessToken struct {
util.CommonError
AccessToken string `json:"component_access_token"`
ExpiresIn int64 `json:"expires_in"`
}
@@ -57,6 +58,10 @@ func (ctx *Context) SetComponentAccessToken(verifyTicket string) (*ComponentAcce
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)
expires := at.ExpiresIn - 1500
if err := ctx.Cache.Set(accessTokenCacheKey, at.AccessToken, time.Duration(expires)*time.Second); err != nil {