Instagram-private-api: how can I use session like old version?

Created on 17 Jun 2019  路  9Comments  路  Source: dilame/instagram-private-api

https://github.com/dilame/instagram-private-api/blob/77798f69255c241b97ae7be8b0a5211b4a2e9841/examples/session.example.ts

I can see that I can save cookie manually, but I don't understand how I can use the cookie I saved.
all I'm trying to do is use cookies when I log in, any ideas?

Most helpful comment

@ngortheone I created a pull request

All 9 comments

Same problem here :(

Instead of using again the method generateDevice() from core/state, initialize and set saved client state.
const ig = new IgApiClient(); ig.state.deviceString = "saved deviceString"; ig.state.deviceId = "saved deviceId"; ig.state.uuid = "saved uuid"; ig.state.phoneId = "saved phoneId"; ig.state.adid = "saved adid"; ig.state.build = "saved build"; await ig.state.deserializeCookieJar(JSON.stringify(cookies));

Yess Man! It's work like a charm! Thank you.

@xIsra @TheFedex87
Could someone update session.example.ts with all relevant things? (serialize device data, restore everything at start)?

I am not nodejs developer and reading js code is hard for me.
Thanks in advance!

@ngortheone I created a pull request

@xlsra so if i return the saved states, does it mean i dont need to login anymore? Because i tried and it doesnt work for me. I still get "required login" error

@iamthewalkingkode use proxy sir

@iamthewalkingkode use proxy sir

When restoring session or login in ?

ok how to restore it ? for future requests
i get this message : IgLoginRequiredError: GET /api/v1/feed/user/623895092/ - 403 Forbidden; login_required

   ig.state.deviceString = savedDevice.deviceString

    ig.state.deviceString = savedDevice.deviceString
    ig.state.deviceId = savedDevice.deviceId
    ig.state.uuid = savedDevice.uuid
    ig.state.phoneId = savedDevice.phoneId;
    ig.state.adid = savedDevice.adid
    ig.state.build = savedDevice.build
    await ig.state.deserializeCookieJar(savedCookie)
    let pk = await ig.user.getIdByUsername(username)
    const userFeed = ig.feed.user('623895092');
    const feed = await userFeed.items();
    console.log(feed, 'fe')
Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikitaulshin picture nikitaulshin  路  17Comments

MMrR0b0TT picture MMrR0b0TT  路  18Comments

ambross picture ambross  路  10Comments

ciolt picture ciolt  路  35Comments

theonlygusti picture theonlygusti  路  11Comments