调试时,非域名,安卓app登录返回出现:{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest, rid: 64f52fbb-3a524517-4d6c6c48"},传递参数:{"code":"041uj00w3VCli13qtz2w3y8Irx1uj00-","grant_type":"authorization_code","appid":"wx7da929f0db83cf4c","secret":"已去掉"},检查了appid、secret都是正确的,不知道是什么原因
看 access_token is invalid or not latest 的意思,,大概率你没有做缓存,导致每一次调用微信后端API,都会重新生成一个 access_token....
https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Authorized_API_call_UnionID.html
接口说明
检验授权凭证(access_token)是否有效
请求说明
GET https://api.weixin.qq.com/sns/auth?access_token=ACCESS_TOKEN&openid=OPENID
到这边都没问题,返回:
errcode:0 errmsg:ok
再调用
openidUrl = "https://api.weixin.qq.com/sns/userinfo?access_token="+access_token+"&openid="+openid+"&lang=zh_CN";
是返回:
errcode:40001,errmsg:invalid credential, access_token is invalid or not latest, rid: 64f544aa-6cf187d1-22a92be7