whatsapp-api icon indicating copy to clipboard operation
whatsapp-api copied to clipboard

Enhancement: Add remote auth

Open ChetanMotghare opened this issue 2 years ago • 3 comments

ChetanMotghare avatar Jul 16 '23 08:07 ChetanMotghare

Hello, can you please provide more details?

chrishubert avatar Jul 17 '23 03:07 chrishubert

Restoring the session The same object you get from the authenticated event can be passed as an option when creating the client:

const { Client, RemoteAuth } = require('whatsapp-web.js');

// Require database
const { MongoStore } = require('wwebjs-mongo');
const mongoose = require('mongoose');

// Load the session data
mongoose.connect(process.env.MONGODB_URI).then(() => {
    const store = new MongoStore({ mongoose: mongoose });
    const client = new Client({
        authStrategy: new RemoteAuth({
            store: store,
            backupSyncIntervalMs: 300000
        })
    });

    client.initialize();
});

currently we are using local authentication , can we use remote auth and store session details on mongo db

ChetanMotghare avatar Jul 18 '23 04:07 ChetanMotghare

@ChetanMotghare we will put that in the roadmap, thanks for the suggestion. If you have time you can also PR 🙂

chrishubert avatar Aug 01 '23 02:08 chrishubert