1、微信h5 appID appSecret配置改从yaml获取

This commit is contained in:
2025-05-11 11:48:10 +08:00
parent 87321ed65a
commit 9ec2e6c104
4 changed files with 15 additions and 4 deletions

View File

@@ -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)