1、微信h5 appID appSecret配置改从yaml获取
This commit is contained in:
parent
b91ea31727
commit
8c4f98a2d5
@ -61,3 +61,6 @@ Ali:
|
|||||||
Code: "d55b58829efb41c8aa8e86769cba4844"
|
Code: "d55b58829efb41c8aa8e86769cba4844"
|
||||||
SystemConfig:
|
SystemConfig:
|
||||||
ThreeVerify: false
|
ThreeVerify: false
|
||||||
|
WechatH5:
|
||||||
|
AppID: "wxa581992dc74d860e"
|
||||||
|
AppSecret: "ba37510206df321279222cecb8614e00"
|
||||||
|
@ -62,3 +62,6 @@ Ali:
|
|||||||
Code: "d55b58829efb41c8aa8e86769cba4844"
|
Code: "d55b58829efb41c8aa8e86769cba4844"
|
||||||
SystemConfig:
|
SystemConfig:
|
||||||
ThreeVerify: true
|
ThreeVerify: true
|
||||||
|
WechatH5:
|
||||||
|
AppID: "wxa581992dc74d860e"
|
||||||
|
AppSecret: "ba37510206df321279222cecb8614e00"
|
||||||
|
@ -19,6 +19,7 @@ type Config struct {
|
|||||||
WestConfig WestConfig
|
WestConfig WestConfig
|
||||||
YushanConfig YushanConfig
|
YushanConfig YushanConfig
|
||||||
SystemConfig SystemConfig
|
SystemConfig SystemConfig
|
||||||
|
WechatH5 WechatH5Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// JwtAuth 用于 JWT 鉴权配置
|
// JwtAuth 用于 JWT 鉴权配置
|
||||||
@ -87,3 +88,7 @@ type YushanConfig struct {
|
|||||||
type SystemConfig struct {
|
type SystemConfig struct {
|
||||||
ThreeVerify bool
|
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) {
|
func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthResp, err error) {
|
||||||
// Step 1: 使用code获取access_token
|
// Step 1: 使用code获取access_token
|
||||||
accessTokenResp, err := GetAccessToken(req.Code)
|
accessTokenResp, err := l.GetAccessToken(req.Code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取access_token失败: %v", err)
|
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
|
// GetAccessToken 通过code获取access_token
|
||||||
func GetAccessToken(code string) (*AccessTokenResp, error) {
|
func (l *WxH5AuthLogic) GetAccessToken(code string) (*AccessTokenResp, error) {
|
||||||
appID := "wxa581992dc74d860e"
|
appID := l.svcCtx.Config.WechatH5.AppID
|
||||||
appSecret := "cfca484cf8cebcccb1f16fbaf1d9fe2c"
|
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)
|
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