Categorygithub.com/ego-component/ewechat
modulepackage
0.0.0-20231113085030-4eb019d41f59
Repository: https://github.com/ego-component/ewechat.git
Documentation: pkg.go.dev

# README

1 微信网页登录

1.1 配置

[wechat]
appID = "xxxx"
appSecret = "xxxx"
redirectUri = "https://xxx.com/code/wechat"
scope = "snsapi_login"

1.2 调用代码

// 初始化
obj := ewechat.Load('key').Build()
oauthInvoker := obj.GetOauth()

// 跳转到微信授权登录
sEnc := base64.RawURLEncoding.EncodeToString(state)
c.Redirect(http.StatusFound, oauthInvoker.AuthCodeURL(econf.GetString("wechat.redirectUri"), econf.GetString("wechat.scope"), sEnc))

// 调用xxx/code 得到授权access
result, err := invoker.WechatOauth2.ExchangeTokenURL(code)
if err != nil {
c.JSONE(1, "exchange token err: "+err.Error(), err)
return
}

// 根据access,调用微信API获取用户信息
userInfo, err := invoker.WechatOauth2.GetUserInfo(result.AccessToken, result.OpenID, "")
if err != nil {
c.JSONE(1, "get user info err: "+err.Error(), err)
return
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

DefaultConfig ...
No description provided by the author
Load ...
No description provided by the author

# Constants

ModName ..

# Structs

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author