Obtain WeChat user information in batches and request WeChat url links multiple times in the loop. The access_token is invalid.

Source: Internet
Author: User
When tens of thousands of pieces of information are obtained, the obtained access_token is carried through multiple request links. However, this error occurs during the running process {& quot; errcode & quot;: 40001, & quot; errmsg & quot;: & quot; invalidcredential, access_tokenisinvalidornotlatest & quot;}, in the loop...

When tens of thousands of pieces of information are obtained, the obtained access_token is carried with the link of multiple requests, but this error occurs during the running process {"errcode": 40001, "errmsg ": "invalid credential, access_token is invalid or not latest"}. The time used to save data during the cycle does not exceed the validity period of access_token. The Code is as follows: what is going on?

Reply content:

When tens of thousands of pieces of information are obtained, the obtained access_token is carried with the link of multiple requests, but this error occurs during the running process {"errcode": 40001, "errmsg ": "invalid credential, access_token is invalid or not latest"}. The time used to save data during the cycle does not exceed the validity period of access_token. The Code is as follows: what is going on?

In addition to the judgment, the Access token will be re-obtained upon expiration
Is there a limit on the number of times?

If the token is valid for 7200 seconds, you should continue to use the token instead of getting it again after 120 seconds. The number of access_token requests per day is limited.

The validity period of access_token is currently 2 hours. You need to refresh it regularly. Repeated access_token acquisition will invalidate the last access_token.

Can I ask you a question about authorization?

Hello, I have encountered a problem similar to yours. in a short period of time, it is always possible to use access_token to call other interfaces.
{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hint: [QZ.Jja0059ent1]"}
I use the timer to get the authorized token every hour and then store it in the memcached cache. Theoretically, this token has been valid for the hour, but the result is that the token will always be invalid every time you frequently use the token to call other interfaces.
The appsecret error is ruled out because if an appsecret error occurs, all call results fail, instead of using the token to frequently call other interfaces.
It takes so long for the subject to solve this problem? Hope that the subject will be taught.

I also encountered a similar problem. I set the validity period of access_token to 3600 s, and I am also a for loop, which sends template messages in the for loop ., In theory, the validity period of access_token is 7200 s, so I set 3600 s to be able to expire and I will pull it again !!

Yes, I don't know why. I used a timer that didn't get the AccessToken for S, but every time I got the AccessToken, I sent the payment customer service message, and it expired in a short time.

During the test, it is found that even if the token is refreshed immediately, it will cause a 42001 error. I don't know why. Please enlighten me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.