component

package
v0.0.0-...-245a666 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NotifyTypeVerifyTicket     = "component_verify_ticket"
	NotifyTypeUnauthorized     = "unauthorized"
	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

type AuthorizerOption struct {
	AuthorizerAppID string
	OptionName      string
	OptionValue     string
}

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 AuthorizerToken struct {
	AppID        string `json:"authorizer_appid"`
	AccessToken  string `json:"authorizer_access_token"`
	RefreshToken string `json:"authorizer_refresh_token"`
	ExpiresIn    int64  `json:"expires_in"`
}

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) GetAppID

func (c Component) GetAppID() string

implements wx.MPAccount

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 (c Component) GetEncodingAESKey() string

func (Component) GetSecret

func (c Component) GetSecret() string

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) 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) StartNotifyHandler

func (c *Component) StartNotifyHandler() chan error

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 IDInfo

type IDInfo struct {
	ID int32 `json:"id"`
}

type MiniProgramCategory

type MiniProgramCategory struct {
	First  string
	Second string
}

type NotifyConfig

type NotifyConfig struct {
	Address             string
	MessageResponsePath string
	AuthRedirectURI     string
}

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

type PreAuthCode struct {
	PreAuthCode string
	ExpiresIn   int64
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL