Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
Why can't my phone scan the QR code generated by Whatsapp API

there are lots of advices on QR codes but I'm unable to find answers to my own problem. So I'm posting this question.

I'm trying to use Whatsapp-web.js, a WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app. Below is the code.

const fs = require('fs');
const { Client } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal');

// Path where the session data will be stored
const SESSION_FILE_PATH = './session.json';

// Load the session data if it has been previously saved
let sessionData;
if(fs.existsSync(SESSION_FILE_PATH)) {
    sessionData = require(SESSION_FILE_PATH);
}

// Use the saved values
const client = new Client({
    session: sessionData
});

// Save session values to the file upon successful auth
client.on('authenticated', (session) => {
    sessionData = session;
    fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), (err) => {
        if (err) {
            console.error(err);
        }
    });
});

client.on('qr', qr => {
    console.log(qr);
    qrcode.generate(qr, {small: true});
});

client.on('ready', () => {
    console.log('Client is ready!');
   
     // Number where you want to send the message.
    const number = "+911234567890";
   
     // Your message.
    const text = "Hey john";
   
     // Getting chatId from the number.
     // we have to delete "+" from the beginning and add "@c.us" at the end of the number.
    const chatId = number.substring(1) + "@c.us";
   
    // Sending message.
    client.sendMessage(chatId, text);
});

client.on('message', message => {
    console.log(message.body);
});

client.initialize();

The problem is that the QR code generated by the Whatsapp client is not recognized by my phone. I wondered if the QR image generator was wrong, so I logged the QR string and pasted it into a QR image generating tool to see if the images were identical. To me the images looked different. But I don't know if that's the problem at all.

I wish to know if there is an additional step I have overlooked before I can scan the QR image with my phone. Currently, I cannot login because phone doesn't recognize the QR image.

Edit

The QR code string is: 1@vFeiIVji3KTIwmxuzrWThEtLYAx1toBQ+gqPI/tpYwg7Nswvybj6z0XqIcKWAkIoQlaIG6+qAy3yfw==,EMaQav3hXijRWQ0Fo54Vi7xINEhOa8ffU1i5tqAzK1s=,cI/NK6CodxcSeyf9niE3Cg==

The QR code image generated by the code is: https://i.stack.imgur.com/LHU1N.png

PS

Would anybody please address the actual problem? As you can see from the code, I'm trying to use Whatsapp API and that requires authentication. This is achieved by scanning the QR code generated by the Whatsapp client. It's not working for me.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda