|
@@ -17,16 +17,23 @@ class WeixinAuthService extends AxiosService {
|
|
|
// TODO:参数检查和默认参数处理
|
|
|
assert(code);
|
|
|
const { wxapi } = this.app.config;
|
|
|
-
|
|
|
- const reqUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';
|
|
|
- const params = {
|
|
|
- appid: wxapi.appid,
|
|
|
- secret: wxapi.appSecret,
|
|
|
- code,
|
|
|
- grant_type: 'authorization_code',
|
|
|
- };
|
|
|
- console.log('rrrr-' + params);
|
|
|
- const res = await this.httpGet(reqUrl, params);
|
|
|
+ const res = await this.httpGet('/api/fetch', { code });
|
|
|
+ if (res.errcode && res.errcode !== 0) {
|
|
|
+ this.ctx.logger.error(
|
|
|
+ `[WeixinAuthService] fetch open by code fail, errcode: ${res.errcode}, errmsg: ${res.errmsg}`
|
|
|
+ );
|
|
|
+ throw new BusinessError(ErrorCode.SERVICE_FAULT, '获得微信认证信息失败');
|
|
|
+ }
|
|
|
+ this.ctx.logger.info(`auth=>${JSON.stringify(res)}`);
|
|
|
+ // const reqUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';
|
|
|
+ // const params = {
|
|
|
+ // appid: wxapi.appid,
|
|
|
+ // secret: wxapi.appSecret,
|
|
|
+ // code,
|
|
|
+ // grant_type: 'authorization_code',
|
|
|
+ // };
|
|
|
+ // console.log('rrrr-' + params);
|
|
|
+ // const res = await this.httpGet(reqUrl, params);
|
|
|
|
|
|
if (res.errcode && res.errcode !== 0) {
|
|
|
this.ctx.logger.error(`[WeixinAuthService] fetch open by code fail, errcode: ${res.errcode}, errmsg: ${res.errmsg}`);
|