im icon indicating copy to clipboard operation
im copied to clipboard

[WhatsApp] Authentication failed since Loqui installed on second device

Open bdcomp opened this issue 10 years ago • 12 comments

0.3.1a on GP Peak, B2G 2.0.0.0-pre, 31/7/2014 build. 0.3.2a on GP Peak, B2G 2.0.0.0-pre, 5/8/2014 build.

Since I activated Loqui on my just received Flatfish (yay!), Loqui can't connect on my phone, with "Authentication failed" error.

Even if WhatsApp account disabled on tablet, Loqui can't connect on the phone.

bdcomp avatar Aug 07 '14 14:08 bdcomp

WhatsApp accounts can only be configured in one device at the same time because every time you set it up it has to be linked to a device ID.

When you configured WhatsApp in Flatfish, Loqui sent the tablet's device ID to WhatsApp servers, so the Peak's ID is now unauthorized to access.

aesedepece avatar Aug 07 '14 15:08 aesedepece

No workaround can't be applied here to?

If one device is in disabled mode, why the other device still can't connect, as it's not like using in the same time?

P.S. "Authentication failed" error should be updated to include this additional error cause.

P.P.S. How I can test Loqui on both my devices?

bdcomp avatar Aug 07 '14 15:08 bdcomp

Although you disable your account in device B, the device ID for A is unauthorized, so you can't log in until you generate a new device ID for A (this only happens during the SMS validating process).

Nevertheless, I believe there's a trick you can use to test Loqui in both devices with the same WhatsApp account. I'll tell you later as I have test it first! :wink:

aesedepece avatar Aug 07 '14 15:08 aesedepece

@aesedepece Any news regarding testing more than one device?

bdcomp avatar Aug 10 '14 20:08 bdcomp

The only way is to move your accounts from device B to device A.

Run this on device B to export your accounts:

var backup = {
    store: [],
    accounts: []
}

function recover (i, cb) {
    if (i < Store.size) {
       Store.recover(i, function (val) {
            backup.store[i] = val;
            recover(i + 1, cb);
       });
    } else {
        cb();
    }
}

function pack (cb) {
    recover(0, function () {
        Store.get('accountsCores', function (val) {
            backup.accounts = val || [];
            console.log(JSON.stringify(backup))
        })
    });
}

pack();

This will result in a huge JSON string with all your accounts, chats, avatars and messages inside. Copy that string and use it to replace the /* HERE */ comment in the code below, to be ran on device A:

var backup = /* HERE */;

function save (i, cb) {
    if (i < backup.store.length) {
        Store.put('b' + i, backup.store[i], function () {
            save(i + 1, cb);
        });
    } else {
        cb();
    }
}

function unpack () {
    asyncStorage.clear();
    backup = JSON.parse(backup);
    Store.put('accountsCores', backup.accounts, function () {
       save(0, function () {
           location.reload();
       }) 
    });
}

unpack();

aesedepece avatar Aug 19 '14 11:08 aesedepece

  1. I am not sure how to run any code on the devices.
  2. The backup data will replace the existed data or just be merged/added?
  3. How about only reactivation, without any backup and restore, #506 ?
  4. The above code is in fact the "developer -> import, export" options? If it's not similar, it looks like we are ready to implement backup and restore options to Loqui.

bdcomp avatar Aug 19 '14 11:08 bdcomp

  1. Via App Manager: https://developer.mozilla.org/en/Firefox_OS/Using_the_App_Manager
  2. They completely replace existing data
  3. Reactivation is theoretically possible but we can't tell a deauthorized account from an invalid account.
  4. Yes, we should bind those menu options to these portions of code, but they need to be modified in order to encrypt the data before writing into the device storage in order to prevent other apps from stealing your data.

aesedepece avatar Aug 19 '14 12:08 aesedepece

Manual reactivation implies copying /.coseme.id file from the microSD card in device B to the one in device A and then running:

On B:

App.accounts[0].core.data.pw;

(This will result in a short random string you have to use to replace the /* HERE */ comment below)

On A:

App.accounts[0].core.data.pw = '/* HERE */';
location.reload();

aesedepece avatar Aug 19 '14 12:08 aesedepece

@aesedepece Manual reactivation didn't work.

On the phone there is still "Authentication failed" error.

bdcomp avatar Aug 20 '14 11:08 bdcomp

So, I tried recovering some of my chats using the steps @aesedepece described above.

The steps above somehow did not work well in my case, they need a little tweaking and reordering. @bdcomp try this if you want.

On the new version, I activated WhatsApp using the SMS activation. Copied the output of App.accounts[0].core.data.pw to some place (this will be used later [1]).

When I was unpacking my backup chats, I faced issues with the string not being recognized properly. There were JSON parsing errors. Maybe because my chats had too many ' and \n. So, I did this,

  • saved the whole backup string to a file
  • searched for \n and replaced them with \n, and ' to '
  • removed the first and the last "
  • pasted the modified backup string in the unpack script
  • commented the backup = JSON.parse(backup); line
  • ran the script. Error.

Then ran App.accounts[0].core.data.pw = <saved data from [1]>. Still got Authentication failure. When I restarted the app, I figured out that the data.pw string has not changed. Then did this:

  • copied the output of App.accounts[0].core.data.pw this time
  • went back to the backup, searched for it
  • replaced it with the data.pw from [1]
  • ran the whole unpack script again.

Bingo! It worked. :smile: However, I lost my chats in this version. :disappointed: I did not touch .coseme.id, though. Never needed it. This should solve the issue. Close it?


I have an older version of Loqui installed that has a lot of chats (literally a lot), so my JSON string is too big to be logged. I have to keep it just in hope that someday someone will find a way to recover the whole data. Does nodejs help somehow? I must work on the backup thing. :expressionless: :confused:

gargsms avatar Oct 10 '14 18:10 gargsms

Hii iam using old version moqui im for som days it worked properly but niw it showing authenticatin failed error plse help me

divyaadupala avatar Nov 05 '15 12:11 divyaadupala

@divyaadupala please see #872

TitanNano avatar Nov 05 '15 13:11 TitanNano