-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
socks5-proxy.example.ts
22 lines (22 loc) · 1013 Bytes
/
socks5-proxy.example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* tslint:disable:no-console */
import 'dotenv/config';
import { IgApiClient } from '../src';
// tslint:disable-next-line:no-var-requires
const shttps = require('socks-proxy-agent'); // you should install SOCKS5 client via: npm i socks-proxy-agent
(async () => {
const ig = new IgApiClient();
ig.state.generateDevice(process.env.IG_USERNAME);
ig.request.defaults.agentClass = shttps; // apply agent class to request library defaults
ig.request.defaults.agentOptions = {
// @ts-ignore
hostname: '127.0.0.1', // proxy hostname
port: 8000, // proxy port
protocol: 'socks:', // supported: 'socks:' , 'socks4:' , 'socks4a:' , 'socks5:' , 'socks5h:'
//username: 'myProxyUser', // proxy username, optional
//password: 'myProxyPassword123', // proxy password, optional
};
// Now we can perform authorization using our SOCKS5 proxy.
const auth = await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
console.log(JSON.stringify(auth));
// Do your things.
})();