Access Token is Invalid Wechat Client
Markl121 opened this issue · 2 comments
Hello I have constructed the request as you specified in your document
https://www.npmjs.com/package/messaging-api-wechat
Code is:
const { WechatClient } = require('messaging-api-wechat');
const client = WechatClient.connect({
appId: process.env.WX_APP_ID,
appSecret: process.env.WX_APP_SECRET,
});
client.sendText(process.env.WX_USERID, msg).catch(error => {
console.log(error); // formatted error message
console.log(error.stack); // error stack trace
console.log(error.config); // axios request config
console.log(error.request); // HTTP request
console.log(error.response); // HTTP response
});
When I run this I get an error:
{ errcode: 40001,
[0] errmsg:
[0] 'invalid credential, access_token is invalid or not latest hint: [FQ4hVA0505hka5!]' } }
I didn't see a place to insert an access_token, and this token appears to change each time I make a request. Could anyone point me in the right direction?
Hi @Markl121, WechatClient
will exchange a new access token using appId
and appSecret
when you rerun the script or the access token expired.
Did you provide the correct appId
and appSecret
?
I can confirm that you will receive this error when you provide a wrong appId
or appSecret
.
We throw the error earlier in #502, so you can use the latest v0.8.4
release to see the problems in your appId
and appSecret
.
https://github.com/Yoctol/messaging-apis/releases/tag/v0.8.4