Documentation
¶
Index ¶
- Constants
- type AuthorizationCode
- type AuthorizationNotifyBody
- type AuthorizationTokenInfo
- type Authorizer
- type AuthorizerOption
- type AuthorizerStorage
- type AuthorizerToken
- type Component
- func (c Component) GetAppID() string
- func (c *Component) GetAuthorizerInfo(authorizerAppID string, timeout int) (info *Authorizer, err error)
- func (c *Component) GetAuthorizerOption(authorizerAppID, optionName string, timeout int) (option *AuthorizerOption, err error)
- func (c Component) GetEncodingAESKey() string
- func (c *Component) GetPreAuthCode(timeout int) (code *PreAuthCode, err error)
- func (c Component) GetSecret() string
- func (c *Component) GrantComponentAccessToken(timeout int) (token *ComponentAccessToken, err error)
- func (c *Component) JumpToOAuth(preAuthCode string) string
- func (c *Component) MPAuthorize(authorizationCode string, timeout int) (auth *AuthorizationTokenInfo, err error)
- func (c *Component) RefreshAuthorizerToken(authorizerAppID, refreshToken string, timeout int) (token *AuthorizerToken, err error)
- func (c *Component) SetAuthorizerOption(option *AuthorizerOption, timeout int) error
- func (c *Component) StartNotifyHandler() chan error
- type ComponentAccessToken
- type ComponentVerifyTicket
- type FunctionInfo
- type IDInfo
- type MiniProgramCategory
- type NotifyConfig
- type NotifyError
- type PreAuthCode
- type Storage
- type VerifyTicketStorage
Constants ¶
const ( NotifyTypeVerifyTicket = "component_verify_ticket" NotifyTypeAuthorized = "authorized" NotifyTypeUpdateAuthorized = "updateauthorized" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizationCode ¶
type AuthorizationCode struct {
AppID string `json:"authorizerAppid,omitempty"`
Code string `json:"authorizationCode,omitempty"`
ExpiredTime int64 `json:"authorizationCodeExpiredTime,omitempty"`
}
AuthorizationCode holds authorizer code
type AuthorizationNotifyBody ¶
type AuthorizationNotifyBody struct {
XMLName xml.Name `xml:"xml"`
AppID string `json:"appId,omitempty" xml:"appId"`
CreateTime int64 `json:"createTime,omitempty" xml:"createTime"`
AuthorizationCode
}
authorization notify request body
type AuthorizationTokenInfo ¶
type AuthorizationTokenInfo struct {
AuthorizationToken AuthorizerToken `json:"authorization_info"`
FuncInfo []FunctionInfo `json:"func_info"`
}
authorization token info
type Authorizer ¶
type Authorizer struct {
AuthorizerInfo struct {
NickName string `json:"nick_name"`
HeadImg string `json:"head_img"`
ServiceTypeInfo IDInfo `json:"service_type_info"`
VerifyTypeInfo IDInfo `json:"verify_type_info"`
UserName string `json:"user_name"`
PrincipalName string `json:"principal_name"`
BusinessInfo map[string]int `json:"business_info"`
Alias string `json:"alias,omitempty"`
QRCodeURL string `json:"qrcode_url"`
Signature string `json:"signature,omitempty"`
MiniProgramInfo struct {
Network struct {
RequestDomain []string `json:"requestdomain"`
WsRequestDomain []string `json:"wsrequestdomain"`
UploadDomain []string `json:"uploaddomain"`
DownloadDomain []string `json:"downloaddomain"`
} `json:"network"`
Categories []MiniProgramCategory `json:"categories"`
VisitStatus int32 `json:"visit_status"`
} `json:"miniprograminfo,omitempty"`
} `json:"authorizer_info"`
AuthorizationInfo struct {
AppID string `json:"appid"`
FuncInfo []FunctionInfo `json:"func_info"`
} `json:"authorization_info"`
}
authorizer info
type AuthorizerOption ¶
authorizer option
type AuthorizerStorage ¶
type AuthorizerStorage interface {
// SetAuthorizerToken when authorized.
SetAuthorizerToken(token *AuthorizerToken)
// GetAuthorizerToken for querying authorizer info if authorized,
// should refresh authorizer token if expired.
GetAuthorizerToken(authorizerAppID string) string
// ClearAuthorizertoken when authorization cancelled.
ClearAuthorizerToken(authorizerAppID string)
// SetAuthorizationInfo after authorized
SetAuthorizationInfo(*AuthorizationTokenInfo)
}
AuthorizerStorage holds authorizer access token
type AuthorizerToken ¶
type Component ¶
type Component struct {
AppID string
Secret string
EncodingAESKey string
SignatureToken string
Address *NotifyConfig
Storage
}
Component services in place of official accounts
func (*Component) GetAuthorizerInfo ¶
func (c *Component) GetAuthorizerInfo(authorizerAppID string, timeout int) (info *Authorizer, err error)
https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=xxxx
func (*Component) GetAuthorizerOption ¶
func (c *Component) GetAuthorizerOption(authorizerAppID, optionName string, timeout int) (option *AuthorizerOption, err error)
https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_option?component_access_token=xxxx
func (Component) GetEncodingAESKey ¶
func (*Component) GetPreAuthCode ¶
func (c *Component) GetPreAuthCode(timeout int) (code *PreAuthCode, err error)
https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=xxx
func (*Component) GrantComponentAccessToken ¶
func (c *Component) GrantComponentAccessToken(timeout int) (token *ComponentAccessToken, err error)
https://api.weixin.qq.com/cgi-bin/component/api_component_token
func (*Component) JumpToOAuth ¶
func (*Component) MPAuthorize ¶
func (c *Component) MPAuthorize(authorizationCode string, timeout int) (auth *AuthorizationTokenInfo, err error)
https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=xxxx
func (*Component) RefreshAuthorizerToken ¶
func (c *Component) RefreshAuthorizerToken(authorizerAppID, refreshToken string, timeout int) (token *AuthorizerToken, err error)
https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=xxxxx
func (*Component) SetAuthorizerOption ¶
func (c *Component) SetAuthorizerOption(option *AuthorizerOption, timeout int) error
https://api.weixin.qq.com/cgi-bin/component/api_set_authorizer_option?component_access_token=xxxx
func (*Component) StartNotifyHandler ¶
type ComponentAccessToken ¶
type ComponentAccessToken struct {
Token string `json:"component_access_token"`
ExpiresIn int64 `json:"expires_in"`
}
{ "component_access_token":"61W3mEpU66027wgNZ_MhGHNQDHnFATkDa9-2llqrMBjUwxRSNPbVsMmyD-yq8wZETSoE5NQgecigDrSHkPtIYA", "expires_in":7200 }
type ComponentVerifyTicket ¶
type ComponentVerifyTicket struct {
XMLName xml.Name `xml:"xml"`
AppID string `xml:"AppId"`
CreateTime int64 `xml:"CreateTime"`
ComponentVerifyTicket string `xml:"ComponentVerifyTicket"`
}
<xml> <AppId> </AppId> <CreateTime>1413192605 </CreateTime> <InfoType> </InfoType> <ComponentVerifyTicket> </ComponentVerifyTicket> </xml>
type FunctionInfo ¶
type FunctionInfo struct {
FuncScopeCategory IDInfo `json:"funcscope_category"`
}
type MiniProgramCategory ¶
type NotifyConfig ¶
NotifyConfig configures notify addresses for wechat message
type NotifyError ¶
type NotifyError struct {
// contains filtered or unexported fields
}
func (NotifyError) Error ¶
func (e NotifyError) Error() string
type PreAuthCode ¶
pre auth code for authorization
type Storage ¶
type Storage interface {
// implements wx.wechatMP
wx.AccessTokenStorage
wx.JSTicketStorage
// component specified interfaces
AuthorizerStorage
VerifyTicketStorage
}
Storage holds component ticket, access token, and authorizer codes, and should be responsible for token refreshing.
type VerifyTicketStorage ¶
type VerifyTicketStorage interface {
GetVerifyTicket() string
SetVerifyTicket(ticket *wx.APITicket)
}
VerifyTicketStorage holds verify ticket for component