1、微信h5 appID appSecret配置改从yaml获取
This commit is contained in:
parent
87321ed65a
commit
9ec2e6c104
@ -61,3 +61,6 @@ Ali:
|
||||
Code: "d55b58829efb41c8aa8e86769cba4844"
|
||||
SystemConfig:
|
||||
ThreeVerify: false
|
||||
WechatH5:
|
||||
AppID: "wx442ee1ac1ee75917"
|
||||
AppSecret: "c80474909db42f63913b7a307b3bee17"
|
||||
|
@ -62,3 +62,6 @@ Ali:
|
||||
Code: "d55b58829efb41c8aa8e86769cba4844"
|
||||
SystemConfig:
|
||||
ThreeVerify: true
|
||||
WechatH5:
|
||||
AppID: "wx442ee1ac1ee75917"
|
||||
AppSecret: "c80474909db42f63913b7a307b3bee17"
|
||||
|
@ -19,6 +19,7 @@ type Config struct {
|
||||
WestConfig WestConfig
|
||||
YushanConfig YushanConfig
|
||||
SystemConfig SystemConfig
|
||||
WechatH5 WechatH5Config
|
||||
}
|
||||
|
||||
// JwtAuth 用于 JWT 鉴权配置
|
||||
@ -87,3 +88,7 @@ type YushanConfig struct {
|
||||
type SystemConfig struct {
|
||||
ThreeVerify bool
|
||||
}
|
||||
type WechatH5Config struct {
|
||||
AppID string
|
||||
AppSecret string
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func NewWxH5AuthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WxH5Auth
|
||||
|
||||
func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthResp, err error) {
|
||||
// Step 1: 使用code获取access_token
|
||||
accessTokenResp, err := GetAccessToken(req.Code)
|
||||
accessTokenResp, err := l.GetAccessToken(req.Code)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取access_token失败: %v", err)
|
||||
}
|
||||
@ -108,9 +108,9 @@ type AccessTokenResp struct {
|
||||
}
|
||||
|
||||
// GetAccessToken 通过code获取access_token
|
||||
func GetAccessToken(code string) (*AccessTokenResp, error) {
|
||||
appID := "wx442ee1ac1ee75917"
|
||||
appSecret := "c80474909db42f63913b7a307b3bee17"
|
||||
func (l *WxH5AuthLogic) GetAccessToken(code string) (*AccessTokenResp, error) {
|
||||
appID := l.svcCtx.Config.WechatH5.AppID
|
||||
appSecret := l.svcCtx.Config.WechatH5.AppSecret
|
||||
|
||||
url := fmt.Sprintf("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", appID, appSecret, code)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user