刚获取的tocken就过期

发布于 6 年前作者 yangtao19554 次浏览最后编辑 6 年前来自 ask

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

@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 回复
jingdeng
jingdeng1 楼6 年前

你好

rjin
rjin2 楼6 年前

我也遇到这么问题了。

yong59
yong593 楼6 年前

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

yan47
yan474 楼5 年前

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