获取access_token接口,设置IP白名单问题,求官方解答

微信支付 文章 2022-04-11 18:40 989 0 全屏看文

AI助手支持GPT4.0

获取access_token接口,设置IP白名单问题,求官方解答Get the access_token interface, set the IP whitelist problem, ask the official answer

获取access_token接口,设置IP白名单问题,求官方解答

我设置了服务器的公网IP进白名单里,可这个access_token接口用的IP是用户的请求IP,按理说用户发送请求到服务器,服务器再发送请求给微信access_token接口,这个接口拿的不应该是我服务器的IP吗?拿用户IP、用户千千万我是不是都得设置他们的IP进去?请官方给个解决方案

I set the public IP of the server into the white list, but this access_ The IP used for the token interface is the user's request IP. Logically, the user sends the request to the server, and the server sends the request to wechat access_ Token interface. Shouldn't this interface take the IP of my server? Do I have to set their IP to get the user IP and tens of millions of users? Please give us a solution

回答:

Mr.Zhao:

微信云托管没出来的时候,大家都没法用了? 获取token是在服务端执行的,跟客户端没关系

Memory:

这里是服务器的IP

鲨仁猪心:是这样吗?我把代码上传到服务器,然后手机测试,手机的wifi和数据是两个不同的IP,然后后端就是返回这个两个IP不在白名单,重来不返回说服务器的公网IP不在白名单,是我那一步错了吗
Memory:报错是什么?
鲨仁猪心:
鲨仁猪心:就是IP错误,这个是我Wifi的IP,我服务器IP是8.134.69.65,也已经设置进白名单里了
Memory:你这是本地测试?
鲨仁猪心:

因为我这个是要使用微信JSAPI支付的,而JSAPI支付要用到openid,openid就需要access_token,那么每有一个用户支付触发JSAPI接口的时候我是不是就要获取一次access_token,但是这个access_token又要设置IP白名单,还是用户网关IP,而不是我服务器固定的公网IP,这要我怎么搞,是我哪里做错了吗?还是说一定要用微信的云托管

-EOF-

AI助手支持GPT4.0