-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid Access Token Error #11
Comments
|
Let me take a look... |
I tried to reproduce your scenario, I see that it might be related to a previous issue in version 1.2.0 on access token expiry time calculation. This issue has been addressed in the latest version of the package (1.3.0) Please let me know if this works for you. |
hi i had the same problem gave me sleepless nights for days here is how i solved it : Use a middleware function to generate the token then call it just before the stkPush route e.g app.post("/stkpush",generateToken,(req,res){} and here is my source code require("dotenv").config(); app.use(express.json()); const getAccessToken = async () => { try {
} catch (error) { // Middleware function to generate access token app.get("/stk", (req, res) => { app.post("/stk", generateToken, async (req, res) => { const date = new Date(); const shortCode = "174379"; // Sandbox: '174379' const stk_password = Buffer.from(shortCode + passkey + timestamp).toString( // Choose one depending on your development environment try {
} catch (error) { app.listen(PORT, () => { |
@xavieromondi I also solved mine the same way... But I appreciate the help 👍 |
I configured everything as guided and it worked. Then I come the next day and rerun the code without changing anything and I get the:
{ "requestId":"5115-78674050-1", "errorCode": "404.001.03", "errorMessage": "Invalid Access Token" }
. So after waiting impatiently, it worked again. This keeps happening. Is there a possibility that it's lagging behind on updating theaccess token
, coz you said that it does that automatically?The text was updated successfully, but these errors were encountered: