open

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeMP    = 1
	AuthTypeWeapp = 2
	AuthTypeAll   = 3
)

表示几种验证类型

Variables

This section is empty.

Functions

func GetComponentAccessToken

func GetComponentAccessToken(appid, appsecret, verityTicket string) (token string, expiresIn int, err error)

GetComponentAccessToken 获取第三方平台 component_access_token

func GetComponentBindURL

func GetComponentBindURL(appid, preAuthCode, redirectURL string, authType AuthType, bizAppID string) string

GetComponentBindURL 生成授权链接

func GetComponentLoginPageURL

func GetComponentLoginPageURL(appid, preAuthCode, redirectURL string, authType AuthType) string

GetComponentLoginPageURL 生成授权引导页网址

func ParseAuthorizationCode

func ParseAuthorizationCode(r *http.Request) (code string, expiresIn int, err error)

ParseAuthorizationCode 从回调地址中获取授权码等信息

用户的确认授权之后的回调地址,数据从 query 中获取。

Types

type AuthType

type AuthType int8

AuthType 验证类型

type AuthorizationInfo

type AuthorizationInfo struct {
	AppID        string      `json:"authorizer_appid"`
	AccessToken  string      `json:"authorizer_access_token"`
	ExpiresIn    int         `json:"expires_in"`
	RefreshToken string      `json:"authorizer_refresh_token"`
	FuncInfo     []*FuncInfo `json:"func_info"`
}

type AuthorizerInfo

type AuthorizerInfo struct {
	Nickname      string `json:"nick_name"`
	Headimg       string `json:"head_img"`
	Username      string `json:"user_name"`
	PrincipalName string `json:"principal_name"`
	QrcodeURL     string `json:"qrcode_url"`
	Signature     string `json:"signature"`
}

type AuthorizerObj

type AuthorizerObj struct {
	Info *AuthorizerInfo `json:"authorizer_info"`
}

func GetAuthorizerInfo

func GetAuthorizerInfo(appid, authorizerAppid, componentAccessToken string) (*AuthorizerObj, error)

GetAuthorizerInfo 获取授权方的公众号帐号基本信息

type AuthorizerToken

type AuthorizerToken struct {
	AccessToken  string `json:"authorizer_access_token"`  // 授权方令牌
	ExpiresIn    int    `json:"expires_in"`               // 有效期,为2小时
	RefreshToken string `json:"authorizer_refresh_token"` // 刷新令牌
}

func GetAuthorizerToken

func GetAuthorizerToken(appid, authorizerAppid, authorizerRefreshToken, componentAccessToken string) (*AuthorizerToken, error)

GetAuthorizerToken 获取(刷新)授权公众号的接口调用凭据(令牌)

type FuncInfo

type FuncInfo struct {
	Scope *Scope `json:"funcscope_category"`
}

type PreAuthCode

type PreAuthCode struct {
	Code    string `json:"pre_auth_code"`
	Expires int    `json:"expires_in"`
}

PreAuthCode 从预授权地址返回的内容

func GetPreAuthCode

func GetPreAuthCode(appid, accessToken string) (*PreAuthCode, error)

GetPreAuthCode 获取预授权码

type QueryAuth

type QueryAuth struct {
	AuthorizationInfo *AuthorizationInfo `json:"authorization_info"`
}

func GetQueryAuth

func GetQueryAuth(appid, authorizationCode, componentAccessToken string) (*QueryAuth, error)

GetQueryAuth 使用授权码换取公众号的接口调用凭据和授权信息

type Scope

type Scope struct {
	ID string `json:"id"`
}

type VerifyTicket

type VerifyTicket struct {
	Root                  xml.Name `xml:"xml"`
	AppID                 string   `xml:"AppId"`
	CreateTime            string   `xml:"CreateTime"`
	InfoType              string   `xml:"InfoType"`
	ComponentVerifyTicket string   `xml:"ComponentVerifyTicket"`
}

VerifyTicket 返回的验证信息

func ParseVerifyTicket

func ParseVerifyTicket(c *crypto.Crypto, w http.ResponseWriter, r *http.Request) (*VerifyTicket, error)

ParseVerifyTicket 处理 component_verify_ticket 事件中返回的数据

Directories

Path Synopsis
Package crypto 消息的加解密功能
Package crypto 消息的加解密功能

Jump to

Keyboard shortcuts

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