forked from dilame/instagram-private-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckpoint.example.ts
More file actions
26 lines (25 loc) · 917 Bytes
/
checkpoint.example.ts
File metadata and controls
26 lines (25 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import 'dotenv/config';
import { IgApiClient, IgCheckpointError } from '../src';
import Bluebird = require('bluebird');
import inquirer = require('inquirer');
(async () => {
const ig = new IgApiClient();
ig.state.generateDevice(process.env.IG_USERNAME);
ig.state.proxyUrl = process.env.IG_PROXY;
Bluebird.try(async () => {
const auth = await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
console.log(auth);
}).catch(IgCheckpointError, async () => {
console.log(ig.state.checkpoint); // Checkpoint info here
await ig.challenge.auto(true); // Requesting sms-code or click "It was me" button
console.log(ig.state.checkpoint); // Challenge info here
const { code } = await inquirer.prompt([
{
type: 'input',
name: 'code',
message: 'Enter code',
},
]);
console.log(await ig.challenge.sendSecurityCode(code));
});
})();