沙箱環境無法通過小程序前端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請求項目后台,由后台向支付寶發起請求獲取會員信息。