pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.21k stars 3.63k forks source link

Bug using authStrategy (LocalAuth) path issue #1364

Closed manuel-marg closed 1 year ago

manuel-marg commented 2 years ago

Is there an existing issue for this?

Describe the bug

Im using a whatsapp No Business acount, program didn't take the default path, it was necessary add it here on client param.

authStrategy: new LocalAuth({ dataPath: './.wwebjs_auth/session' })

this was added because client created another session everytime the project runs instead to take created session at first run.

Whereas using Whatsappp Business acount, client take directly default path. it's not necesary to add parameter: "dataPath".

If I added on this case the parameter dataPath, client created another folder called session and inside of this folder created another session folder with session data. Client never used session created because it can't found on this path.

Hope this help somebody. Thanks.

Expected behavior

As user I expected to use LocalAuth without parameters and client could find and use default dataPath "./.wwebjs_auth/session"

Using whatsapp Business and whatsapp not Business.

Steps to Reproduce the Bug or Issue

Case 1: Use a Whatsapp Business acount. Use authStrategy: new LocalAuth({ dataPath: './.wwebjs_auth/session' }) On client Error, client create another session folder on project and auth data is on ./.wwebjs_auth/session/session instead of ./.wwebjs_auth/session

Case 2: Use a Whatsapp NOT Business acount. Use authStrategy: new LocalAuth() On client Session created succefull first run Error, on nexts runs client don't found session data and generate another QR code.

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

Windows 10 64 bits Node.js 12.18.4

Additional context

No response

hamza-masoud commented 2 years ago

read here this will help you to save the session and explain how it work in multi device https://wwebjs.dev/guide/authentication.html#noauth-strategy and there is new update for whatsapp and in this update leaving the multi device is not allowed so henceforth all the session will save using Local Auth so check the update and the code will work

also LocalAuth is created for multi device and you are not using it so you should use LegacySessionAuth rather than it

shirser121 commented 1 year ago

Please look over here https://wwebjs.dev/guide/authentication.html#localauth-strategy