刚获取的tocken就过期
发布于 5 年前 作者 yangtao 19393 次浏览 来自 问答

刚获取tocken,然后拿去获取小程序码,返回结果总是提示tocken过期了。代码如下:

[@Test](/user/Test)
 public void httpTest(){
     String url = "https://api.weixin.qq.com/cgi-bin/token";
     String params ="grant_type=client_credential&appid="+ appId +"&secret=" + secret;
 
     String result = HttpRequest.sendGet(url,params);
     System.out.println("---->");
     String tocken = result.toLowerCase();
     String Codeurl = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + tocken;
     String codeParms = "page=/index/index&width=200&scene=1&is_hyaline=false&auto_color=false&line_color={“r”:”0”,”g”:”0”,”b”:”0”}";
     String codeRes = HttpRequest.sendPost(Codeurl, codeParms);
     System.out.println("获取二维码成功!");
     System.out.println(codeRes);
      
 }

返回结果如下:

{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hint: [2YYoSa06932862!]"}

请问有没有人遇到过这种问题啊?在线等,急急急!

4 回复

我也遇到这么问题了。

注意token和account_token,获取微信二维码使用的account_token和微信支付授权等token不是同一个接口获取的

AppSecret应该是正确的吧,获取open Id的时候都能用。

回到顶部