Skip to content
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

qr code not working #69

Open
ghost opened this issue May 6, 2022 · 1 comment
Open

qr code not working #69

ghost opened this issue May 6, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented May 6, 2022

I try to node api.js and run in terminal,then I access ip:5000/auth/getqr ,Qr in that url doesn't work,and every time I refresh,the token in components/last.qr doesn't change

this is the code in api.js
`const express = require("express");
const bodyParser = require("body-parser");
const fs = require("fs");
const axios = require("axios");
const shelljs = require("shelljs");

const config = require("./config.json");
const { Client, LocalAuth } = require("whatsapp-web.js");

process.title = "whatsapp-node-api";
global.client = new Client({
authStrategy: new LocalAuth(),
puppeteer: {
headless: true,
args: ['--no-sandbox']
},
});

global.authed = false;

const app = express();

const port = process.env.PORT || config.port;
//Set Request Size Limit 50 MB
app.use(bodyParser.json({ limit: "50mb" }));

app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));

client.on("qr", (qr) => {
console.log("qr");
fs.writeFileSync("./components/last.qr", qr);
});

client.on("authenticated", () => {
console.log("AUTH!");
authed = true;

try {
fs.unlinkSync("./components/last.qr");
} catch (err) {}
});

client.on("auth_failure", () => {
console.log("AUTH Failed !");
process.exit();
});

client.on("ready", () => {
console.log("Client is ready!");
});

client.on("message", async (msg) => {
if (config.webhook.enabled) {
if (msg.hasMedia) {
const attachmentData = await msg.downloadMedia();
msg.attachmentData = attachmentData;
}
axios.post(config.webhook.path, { msg });
}
});
client.on("disconnected", () => {
console.log("disconnected");
});
client.initialize();

const chatRoute = require("./components/chatting");
const groupRoute = require("./components/group");
const authRoute = require("./components/auth");
const contactRoute = require("./components/contact");

app.use(function (req, res, next) {
console.log(req.method + " : " + req.path);
next();
});
app.use("/chat", chatRoute);
app.use("/group", groupRoute);
app.use("/auth", authRoute);
app.use("/contact", contactRoute);

app.listen(port, () => {
console.log("Server Running Live on Port : " + port);
});`

@jhernancanom
Copy link

jhernancanom commented Jul 6, 2022

Me too.
This is the QR image generated, but the phone does not read it: no err, just not read.
I zoom it a little bigger (I also zoom it shorter), but nothing happens: the WtahsApp QR reader does not read it.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant