Documentation ¶
Index ¶
- Constants
- Variables
- func AddToken(id string, app *AppItem)
- func ChangeSecret(id string, secret string) error
- func ComponentUrl(acsKey string, uri string) string
- func DefaultForm(w *multipart.Writer, field, filename string) error
- func DefaultUrl(acsKey string, uri string) string
- func DeleteToken(id string) error
- func EmptyUrl(acsKey string, uri string) string
- func ErrEq(err error, o Result) bool
- func GenId(componentId, appId string) string
- func GenIdWithType(ty, componentId, appId string) string
- func GetEmpty(tk Token, d data.D) (access.Token, error)
- func GetId(componentId, appId string) string
- func GetIdWithType(ty, componentId, appId string) string
- func PermanentCodeKey(corpId string) string
- func SyncCreateChild(parent Token, service Service, ch *Child, acsToken access.Token, ...)
- type Api
- func (api *Api) AppId() string
- func (api *Api) Clone() *Api
- func (api *Api) GetAccessToken() (string, error)
- func (api *Api) IsDebug() bool
- func (api *Api) Request(method, uri string, buf []byte, resCb ApiResCallBack) error
- func (api *Api) ResetToken()
- func (api *Api) Secret() string
- func (api *Api) Upload(uri string, field string, file Form, resCb ApiResCallBack) error
- func (api *Api) WithOptions(opts ...ApiOption) *Api
- type ApiBuildUrlFunc
- type ApiGetTokenFunc
- type ApiOption
- func WithAppId(appId string) ApiOption
- func WithAppendData(src data.D) ApiOption
- func WithBuildUrl(fn ApiBuildUrlFunc) ApiOption
- func WithDebug() ApiOption
- func WithGetTokenFunc(fn ApiGetTokenFunc) ApiOption
- func WithHeadFunc(fn ApiSetHeadFunc) ApiOption
- func WithSecret(secret string) ApiOption
- func WithSeqNo(no string) ApiOption
- func WithSetData(key string, val interface{}) ApiOption
- func WithSetTokenFunc(fn ApiSetTokenFunc) ApiOption
- func WithToken(token string) ApiOption
- func WithTryCount(count int) ApiOption
- type ApiResCallBack
- type ApiSetHeadFunc
- type ApiSetTokenFunc
- type App
- type AppItem
- type AppMgr
- func (m *AppMgr) AddRealId(realId []string, id string, ty string) error
- func (m *AppMgr) AddToken(id string, app *AppItem)
- func (m *AppMgr) ChangeSecret(id string, secret string) error
- func (m *AppMgr) Clear(id string, key string) error
- func (m *AppMgr) CreateChild(parent Token, info *Child, service Service) (Token, error)
- func (m *AppMgr) DeleteRealId(ty string, realId string) error
- func (m *AppMgr) DeleteToken(id string) error
- func (m *AppMgr) GetList() []*AppItem
- func (m *AppMgr) GetRealId(ty string, realId string) (string, bool)
- func (m *AppMgr) GetToken(id string) (Token, error)
- func (m *AppMgr) HasToken(id string) bool
- func (m *AppMgr) LoadApp() []App
- func (m *AppMgr) PrintAllOffline()
- func (m *AppMgr) Read(id string, key string) (validate.Data, error)
- func (m *AppMgr) Save(async bool)
- func (m *AppMgr) SetAccessToken(id string, acs access.Token) string
- func (m *AppMgr) Write(id string, key string, v *validate.Data) error
- type Base
- type CheckErrorFunc
- type Child
- type Config
- type ConfigOptions
- type CreateChildFunc
- type FUpdate
- type Form
- type GenFunc
- type GetUrlFunc
- type Item
- type RealId
- type Request
- type ResCode
- type ResToken
- type Result
- func (r Result) Clone(subCode string, err string) Result
- func (r Result) Error() string
- func (r Result) GetCode() int32
- func (r Result) GetMsg() string
- func (r Result) GetSubCode() string
- func (r Result) Is(err error) bool
- func (r Result) IsTokenError() bool
- func (r Result) IsTryCount() bool
- func (r Result) Ok() bool
- type ResultObject
- type Service
- type Ticket
- type Token
- func CreateChild(parent Token, service Service, ch *Child, acsToken access.Token) (Token, error)
- func CreateChildEmpty(tk Token, sev Service, ch *Child, acsToken access.Token) (Token, error)
- func GetRealId(ty string, realId string) (Token, error)
- func GetToken(id string) (Token, error)
- func New(app *App, service Service) Token
- type VMap
Constants ¶
View Source
const ( NAccessToken = "access:token" /*自己本身的access token*/ NRefreshToken = "access:token:refresh" /*刷新自己本身access token */ NTicket = "get:ticket" NOauth2 = "oauth2" /*网页,个人授权*/ NOauthAccount = "oauth2:account" NOauth2App3 = "oauth2:app3" /*第三方应用授权,比把公众号授权给某个应用*/ NPreAuthCode = "app3:pre_auth_code" /* for 公众号授权给第三方,需要先获取一个 预授权码,然后调用前端授权页面进行授权,授权成功后会给一个授权码 "authorization_code" 然后用这个 authorization_code去调用 NOauth2App3,获取到 access token 相关信息 */ NAccessTokenProxy = "access:token:proxy" /* 进行代理,中转,从别的服务器获取token相关信息 */ NGetOwner = "get:owner" )
View Source
const ( PermanentInfo = "permanentInfo" PermanentCode = "permanent_code" AgentId = "agentId" SuiteType = "suiteType" Owner = "owner" Parent = "parent" Secret = "secret" True = "true" Encoder = "encoder" Decoder = "decoder" TicketType = "ticket_type" )
View Source
const ( BaiduType = "baidu" FeiShuType = "feishu" FxgType = "fxg" GdtType = "gdt" GdtAdvType = "gdt.adv" OceanType = "ocean" OceanAdvType = "ocean.adv" WxType = "wx" WxWebType = "wx.web" WxApp3Type = "wx.app3" WxApp3IdType = "wx.app3.id" WxApp3WebType = "wx.app3.web" WxWorkType = "wx.work" //企业微信自建应用 WxWorkMsgAuditType = "wx.work.msg.audit" //会话内容存档,可以ignore,与自建应用一样 WxWorkProviderType = "wx.work.service.provider" //服务商 WxWorkSuiteType = "wx.work.service.suite" //第三方应用及模板 WxWorkCorpType = "wx.work.service.corp" //第三方应用授权企业 WxWorkAgentType = "wx.work.service.agent" //代应用 )
Variables ¶
View Source
var ( ErrNotSupported = Result{Code: -1, SubCode: "support", Msg: "不支持"} ErrTokenExpired = Result{Code: -2, SubCode: "token", Msg: "access token过期"} ErrTokenInvalid = Result{Code: -3, SubCode: "token", Msg: "access token无效"} ErrObjectNil = Result{Code: -4, SubCode: "object", Msg: "对象为空"} ErrParam = Result{Code: -5, SubCode: "param", Msg: "参数错误"} )
View Source
var FormType = reflect.TypeOf((*Form)(nil)).Elem()
Functions ¶
func ChangeSecret ¶ added in v1.0.32
func ComponentUrl ¶
func DefaultUrl ¶
func DeleteToken ¶
func GenIdWithType ¶ added in v1.0.54
func GetIdWithType ¶ added in v1.0.54
func PermanentCodeKey ¶ added in v1.0.53
Types ¶
type Api ¶ added in v1.0.0
type Api struct {
// contains filtered or unexported fields
}
func (*Api) GetAccessToken ¶ added in v1.0.2
func (*Api) Request ¶ added in v1.0.0
func (api *Api) Request(method, uri string, buf []byte, resCb ApiResCallBack) error
func (*Api) ResetToken ¶ added in v1.0.0
func (api *Api) ResetToken()
func (*Api) WithOptions ¶ added in v1.0.0
type ApiBuildUrlFunc ¶ added in v1.8.12
type ApiGetTokenFunc ¶ added in v1.0.0
type ApiOption ¶ added in v1.8.44
type ApiOption func(api *Api)
func WithAppendData ¶ added in v1.8.120
func WithBuildUrl ¶ added in v1.8.44
func WithBuildUrl(fn ApiBuildUrlFunc) ApiOption
func WithGetTokenFunc ¶ added in v1.8.44
func WithGetTokenFunc(fn ApiGetTokenFunc) ApiOption
func WithHeadFunc ¶ added in v1.8.44
func WithHeadFunc(fn ApiSetHeadFunc) ApiOption
func WithSecret ¶ added in v1.8.44
func WithSetData ¶ added in v1.8.120
func WithSetTokenFunc ¶ added in v1.8.44
func WithSetTokenFunc(fn ApiSetTokenFunc) ApiOption
func WithTryCount ¶ added in v1.8.44
type ApiResCallBack ¶ added in v1.8.112
type ApiResCallBack func(hp *commonhttp.Http, body []byte) error
type ApiSetHeadFunc ¶ added in v1.0.0
type ApiSetTokenFunc ¶ added in v1.0.0
type App ¶
type AppItem ¶ added in v1.0.0
type AppItem struct {
// contains filtered or unexported fields
}
func NewAppItem ¶ added in v1.0.0
func NewAppItem(app App, tk Token, options ...ConfigOptions) *AppItem
type AppMgr ¶
type AppMgr struct {
// contains filtered or unexported fields
}
func (*AppMgr) ChangeSecret ¶ added in v1.0.31
func (*AppMgr) CreateChild ¶
func (*AppMgr) DeleteRealId ¶ added in v1.0.55
func (*AppMgr) DeleteToken ¶
func (*AppMgr) PrintAllOffline ¶ added in v1.8.126
func (m *AppMgr) PrintAllOffline()
type CheckErrorFunc ¶ added in v1.0.28
type CheckErrorFunc func(result ResultObject) error
type ConfigOptions ¶ added in v1.0.4
type ConfigOptions func(conf *Config)
type CreateChildFunc ¶ added in v1.0.0
type GetUrlFunc ¶ added in v1.0.0
type Request ¶ added in v1.0.28
type Request interface { BuildUrl(uri string, acsKey string, d data.D) string SetHead(h *http.Header, acsKey string) SetCheckError(check CheckErrorFunc) CheckError(err error) error }
Request GetUrl for request
type Result ¶ added in v1.0.28
func TryCountError ¶ added in v1.8.112
func TryCountError() Result
func (Result) GetSubCode ¶ added in v1.0.28
func (Result) IsTokenError ¶ added in v1.8.8
func (Result) IsTryCount ¶ added in v1.8.8
type ResultObject ¶ added in v1.8.8
type Ticket ¶
func (Ticket) GetAccessToken ¶ added in v1.8.56
func (Ticket) GetRefAccessToken ¶ added in v1.8.56
type Token ¶
type Token interface { Parent() Token CreateChild(app *App, service Service) Token String() string IsCache() bool GetParentId() string GetId() string GetName() string GetAppType() string GetAppId() string GetSecret() string SetSecret(secret string) GetAccessToken(options ...data.OptionsFunc) (string, error) SetAccessTokenWithAcs(acs access.Token) string SetAccessToken(tk string, expire int64) error ClearAccessToken() SetRefreshAccessToken(tk string, expire int64) error RefreshAccessToken(refToken string) (string, error) GetCode(name string) (string, error) ClearCode(name string) error SetCode(name, code string, expire int64) error GetRequest() Request // Execute data["appid"] Execute(cmd string, d data.D) (interface{}, error) }
func CreateChild ¶ added in v1.0.0
func CreateChildEmpty ¶ added in v1.0.0
Source Files ¶
Click to show internal directories.
Click to hide internal directories.