支付宝小程序开发,沙箱环境获取authCode

沙箱环境无法通过小程序前端api的my.getAuthCode获取authCode。

只能通过拼写授权链接获取authCode。

https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=xxxxxxxx&scope=auth_user&redirect_uri=http:127.0.0.1:8000/third-user/test

说明:app_id:沙箱的appId;redirect_uri:随便填写一个项目访问路径。

获取到的结果:

http://127.0.0.1:8081/pay/alipayTradeCreate?app_id=2021000118636093&source=alipay_wallet&scope=auth_user&auth_code=47e06ec38313406d95fc750efcdfWX91

用这种方式获取到的autuCode可代替my.getAuthCode。解决my.getAuthCode无法在沙箱环境获取authCode的问题。

然后再使用authCode请求项目后台,由后台向支付宝发起请求获取会员信息。

 
原文地址:https://www.cnblogs.com/super-chao/p/15450199.html