wppconnect-team / wppconnect-server

Wppconnect Server is a ready-to-use API, just download, install, and start using, simple as that.
https://wppconnect.io/swagger/wppconnect-server/
Apache License 2.0
613 stars 348 forks source link

Link via phone number instead of QR #1687

Open YosefAdPro opened 5 months ago

YosefAdPro commented 5 months ago

https://github.com/wppconnect-team/wppconnect/issues/2031

Saifallak commented 3 months ago

Next release of @wppconnect-server

ref: https://github.com/wppconnect-team/wppconnect/issues/1921#issuecomment-1986845431

aymansyam commented 3 months ago

is this as simple as adding this in createSessionUtil()?

phoneNumber: client.config?.phoneNumber,

I've tried it locally but it doesn't return the link code for some reason :(

Also, a new route similar to POST /qrcode-session which gets you the link code would be nice.

icleitoncosta commented 3 months ago

is this as simple as adding this in createSessionUtil()?

phoneNumber: client.config?.phoneNumber,

I've tried it locally but it doesn't return the link code for some reason :(

Also, a new route similar to POST /qrcode-session which gets you the link code would be nice.

So that's one way. At the moment we have not yet implemented it in a standard way on the server, it will soon be implemented in the next release.


      const wppClient = await create(
        Object.assign(
          {},
          { tokenStore: myTokenStore },
          req.serverOptions.createOptions,
          {
            session: session,
            phoneNumber: '5521999999999',
            deviceName:
              client.config?.deviceName || req.serverOptions.deviceName,
            poweredBy:
              client.config?.poweredBy ||
              req.serverOptions.poweredBy ||
              'WPPConnect-Server',
[...code....]
aymansyam commented 3 months ago

With the newest release, I tried the above but still it doesn't output the code in the terminal.

After some debugging I found that it gets stuck in evaluateAndReturn:


  protected async loginByCode(phone: string) {
    const code = await evaluateAndReturn(
      this.page,
      async ({ phone }) => {
        return JSON.parse(
          JSON.stringify(await WPP.conn.genLinkDeviceCodeForPhoneNumber(phone))
        );
      },
      { phone }
    );

For some reason, when the wppconnect is ran through wppconnect-server, WPP.conn.genLinkDeviceCodeForPhoneNumber does not return at all. It's weird because wppconnect by itself does return the code, so this may be a configuration issue on wppconnect-server.

aymansyam commented 2 months ago

Hi, is this feature still gonna get added?

jaygent commented 1 month ago

With the newest release, I tried the above but still it doesn't output the code in the terminal.

After some debugging I found that it gets stuck in evaluateAndReturn:

  protected async loginByCode(phone: string) {
    const code = await evaluateAndReturn(
      this.page,
      async ({ phone }) => {
        return JSON.parse(
          JSON.stringify(await WPP.conn.genLinkDeviceCodeForPhoneNumber(phone))
        );
      },
      { phone }
    );

For some reason, when the wppconnect is ran through wppconnect-server, WPP.conn.genLinkDeviceCodeForPhoneNumber does not return at all. It's weird because wppconnect by itself does return the code, so this may be a configuration issue on wppconnect-server.

did you manage to find a solution to the problem?

This is the only way getting the code works

const wppClient = await create({
        session: session,
        phoneNumber: '55555555555',
        catchLinkCode: (code: string) => {
          console.log(code);
        },
        autoClose: 1000000,
      });
jaygent commented 1 month ago

if you delete this

deviceName:
              client.config?.deviceName || req.serverOptions.deviceName,
            poweredBy:
              client.config?.poweredBy ||
              req.serverOptions.poweredBy ||
              'WPPConnect-Server',

then everything works