W
W
WarmyxPro2022-02-09 12:24:15
Node.js
WarmyxPro, 2022-02-09 12:24:15

The code from two-factor authorization does not come. VK-IO, what to do?

Hello everyone, I use the VK-IO library. I do authorization through it using the @vk-io/authorization add-on. I don't receive a two-factor authentication code, no errors. It just doesn't come here is the code:

const { CallbackService, ICallbackServiceTwoFactorPayload, CallbackServiceRetry } = require("vk-io");
const { DirectAuthorization, officialAppCredentials } = require("@vk-io/authorization");
const readline = require("readline");
const { config } = require("dotenv");
config();

const readLine = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

const callbackService = new CallbackService();

callbackService.onTwoFactor((payload = ICallbackServiceTwoFactorPayload, retry = CallbackServiceRetry) => {
    readLine.question("Enter VK code:", answer => {
        retry(answer).then(console.log).catch(console.error);
    });
});

const direct = new DirectAuthorization({
    callbackService,

    scope: 'all',

    // Direct authorization is only available for official applications
    ...officialAppCredentials.android, // { clientId: string; clientSecret: string; }

    // Or manually provide app credentials
    // clientId: process.env.CLIENT_ID,
    // clientSecret: process.env.CLIENT_SECRET,

    login: '11111',
    password:'111111'
});

async function run() {
    const response = await direct.run();

    console.log('Token:', response.token);
    console.log('Expires:', response.expires);

    console.log('Email:', response.email);
    console.log('User ID:', response.userId);
}

run().catch(console.error);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question