First of all, awesome works guys!

I’m trying to login via qr code, so, reading the docs I generated a login token via:

    ...
    const client = new TelegramClient(stringSession, Number(apiId), apiHash, {
      connectionRetries: 5,
    });

    await client.connect();

    const loginToken: Api.auth.TypeLoginToken = await client.invoke(
      new Api.auth.ExportLoginToken({
        apiId: Number(apiId),
        apiHash,
        exceptIds: [9505834],
      }),
    );
    if (!(loginToken instanceof Api.auth.LoginToken)) {
      return;
    }
    console.log(`tg://login?token=${loginToken.token.toString('base64url')}`);
    ...

After that, I scanned the returned url in my phone. So, how can I start the client using this token? what is the correct use of client.start(<AuthUser>)? The AuthuUser interface impose phoneCode use, but I want to login only via qr code.

Thanks for the help.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
painorcommented, Sep 10, 2021

Should be fixed in latest patch. There was actually a piece of code in the library that made qr login broken 😕 I’ve added an example in the docs as well.

    const user = await client.signInUserWithQrCode({ apiId, apiHash },
        {
            onError: async function(p1: Error) {
                console.log("error", p1);
                // true = stop the authentication processes
                return true;
            },
            qrCode: async (code) => {
                console.log("Convert the next string to a QR code and scan it");
                console.log(
                    `tg://login?token=${code.token.toString("base64url")}`
                );
            },
            password: async (hint) => {
                // password if needed
                return "1111";
            }
        }
    );
    console.log("user is", user);

2reactions
painorcommented, Sep 9, 2021

There is already a helper method for QR codes. signInUserWithQrCode. you can take a look on how it implements it.

Basically after you scan the code telegram would send you an event. after which you need to call ExportLoginToken again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Login - QR Code Generator PRO
No account yet? Sign up. ​. Email. ​. Password. Keep me signed in. Forgot password? Log In. or. Sign in with a Google...
Read more >
QR Code Generator | Create Your Free QR Codes
QR Code Generator for URL, vCard, and more. Add logo, colors, frames, and download in high print quality. Get your free QR Codes...
Read more >
How to Use QR Codes For Easier Login Authentication Across ...
Deploy QR codes designed especially for mobile apps. ... Using QR codes, you can make the login process an excellent user experience.
Read more >
Login - Free Custom QR Code Maker and Creator with logo
Log In to Your QR Tiger Account! Continue with Google. Remember me. Sign in. Forgot password. Don't have an account?
Read more >
How to Create Student Clever QR Codes to Log In - YouTube
How to Create Student Clever QR Codes to Log In ... QR Code login using Laravel and qrcode.js. WebDevWithArtisan. WebDevWithArtisan.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found