yatsenkolesh / instagram-nodejs

Simple library for auth, get followers, search by hashtags and locations, like posts, follow, get user feed of instagram with nodejs
MIT License
317 stars 74 forks source link

Instagram.sessionId is undefined every time. #62

Open EddyVinck opened 4 years ago

EddyVinck commented 4 years ago

Does this package still work for anyone?

Here is a (slightly changed) example from the README:

Instagram.getCsrfToken()
  .then((csrf) => {
    Instagram.csrfToken = csrf;
  })
  .then(() => {
    return Instagram.auth(this.config.username, this.config.password).then(
      (sessionId) => {
        console.log(sessionId); // undefined
        Instagram.sessionId = sessionId;

        // ...
      }
    );
  })
  .catch(console.error);
Mrjavaci commented 4 years ago

I have the same problem.

Valadares-A commented 4 years ago

I have the same problem too.

JAlbertoGonzalez commented 4 years ago

https://github.com/yatsenkolesh/instagram-nodejs/blob/4c847a668329ae61c42d2bdfc0b8d282397e565d/instagram.js#L285-L291

The auth() method is always returning a 404 Bad Request reply. SessionId is never set due to this issue. So this package is not updated to the current auth method required by IG.

Valadares-A commented 3 years ago

Still not working?

Thibaultfq commented 3 years ago

https://github.com/yatsenkolesh/instagram-nodejs/blob/4c847a668329ae61c42d2bdfc0b8d282397e565d/instagram.js#L285-L291

The auth() method is always returning a 404 Bad Request reply. SessionId is never set due to this issue. So this package is not updated to the current auth method required by IG.

Any references or documentation on the new auth method and url? I assume this is now done use GraphQL? Maybe i could open another pull request if i get this to work.

Current workaround: copy your csrf and sessionid cookies from the instagram.com page after using their official login and use these in this API.

      const  instagram = new Instagram();
      instagram.csrfToken = cookies.csrf;
      instagram.sessionId = cookies.sessionid;
pegah5665 commented 3 years ago

I have the same problem

julianmendonca commented 2 years ago

I managed to get the sessionId cookie by writing a simple cypress test that login into instagram and write a .txt file with the sessionId cookie. You can run this test and chain another script to read the cookie and use this library.

This test may need some changes in the future depending on instagram changes, but you get the idea

describe("Create cookie", () => {
  it("Creates cookie", () => {
    cy.visit("https://www.instagram.com/");
    cy.get('[name="username"]').type("useremail");
    cy.get('[name="password"]').type("userpassword").type("{enter}");
    cy.wait(5000);
    cy.getCookie("sessionid").then((cookie) => {
      cy.writeFile("cookie.txt", cookie.value);
      cy.wait(2000);
      cy.exec("node cypress/e2e/instagram.js");
    });
  });
});