instagram-private-api: CookieNotValidError

Hi! Everything worked for me. And now suddenly ceased with here such here error.

{“name”:“CookieNotValidError”,“message”:“Cookie sessionid you are searching found was either not found or not valid!”}

Nothing changed in the code. Cookies cleaned. What could be the reason?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 33 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Workaround if you are building against a local copy of instagram-private-api, change /v1/cookie-storage.js line 21 from

self.storage.findCookie(CONSTANTS.HOSTNAME, '/', name, function(err, cookie) {

to

self.storage.findCookie('instagram.com', '/', name, function(err, cookie) {

I refactored this to CONSTANTS.COOKIE_DOMAIN.

Seems to work, not sure of the ramifications… Changing CONSTANTS.HOSTNAME breaks other things, leave it alone. I’m sure there’s a better fix, but I don’t know enough about the cookie implementation to offer a real PR.

\client\v1\jar.js

RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) {
    cookieOrStr = cookieOrStr.replace(/Domain=\.?instagram\.com;\s?/,'');
    uri = this.rewriteUri(uri);
    return this._jar.setCookieSync(cookieOrStr, uri, options || {});
};

Sorry, but hot-patching third-party code shouldn’t be the preferred way to fix problems. @IvanMMM is there any chance you could do a PR so this can be fixed and merged and packaged right away?

Hey, To everyone that tackles this in the future I managed to get it working. This problem was fixed in version 0.7, but you can’t get it from NPM yet. If you will install this library with npm you will get 0.6.8(At this moment of writing this). to download the specific updated working version try to add this to package.json:

“instagram-private-api”: “git://github.com/huttarichard/instagram-private-api#0.7.0”

and run npm install afterwards. This way the module will be installed directly from github and not from NPM.

https://github.com/dilame/instagram-private-api/issues/596#issuecomment-453927349

Hey guys,

I’m still getting a

"CookieNotValidError: Cookie `sessionid` you are searching found was either not found or not valid!"

after installing the most recent version. "instagram-private-api": "^0.6.7",

@yuceltoluyag >= 0.7 Version still having issues with cookies, look https://github.com/dilame/instagram-private-api/issues/632

Using 0.7 Version and old cookies work while changing i.instagram.com to instagram.com, but i found that is not always working, i am getting CookieNotValidError sometimes but is is disastrous because it is writing user.json files empty with 0kb, and it is breaking all functions

Delete igdm-cli/node_modules/instagram-private-api folder and change ur package.json

{
  "_from": "igdm-cli",
  "_id": "igdm-cli@0.5.3",
  "_inBundle": false,
  "_integrity": "sha1-YUMioIUsUdH85o3KrYaqPqky4Dc=",
  "_location": "/igdm-cli",
  "_phantomChildren": {},
  "_requested": {
    "type": "tag",
    "registry": true,
    "raw": "igdm-cli",
    "name": "igdm-cli",
    "escapedName": "igdm-cli",
    "rawSpec": "",
    "saveSpec": null,
    "fetchSpec": "latest"
  },
  "_requiredBy": [
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/igdm-cli/-/igdm-cli-0.5.3.tgz",
  "_shasum": "614322a0852c51d1fce68dcaad86aa3ea932e037",
  "_spec": "igdm-cli",
  "_where": "/home/friday13",
  "bin": {
    "igdm": "bin/index.js"
  },
  "bugs": {
    "url": "https://github.com/mathdroid/igdm-cli/issues"
  },
  "bundleDependencies": false,
  "dependencies": {
    "babel-runtime": "^6.26.0",
    "bignumber.js": "^5.0.0",
    "chalk": "^2.3.0",
    "has-ansi": "^3.0.0",
    "inquirer": "^4.0.2",
    "instagram-private-api": "git://github.com/huttarichard/instagram-private-api#0.7.0",
    "keypress": "^0.2.1",
    "log-update": "^2.3.0",
    "moment": "^2.20.1",
    "mri": "^1.1.0",
    "ms": "^2.1.1",
    "ora": "^1.3.0",
    "update-notifier": "^2.3.0"
  },
  "deprecated": false,
  "description": "> Instagram's direct message, right in your terminal.",
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "np": "^2.20.1",
    "release": "^3.0.3"
  },
  "files": [
    "package.json",
    "README.md",
    "bin"
  ],
  "homepage": "https://github.com/mathdroid/igdm-cli#readme",
  "license": "MIT",
  "name": "igdm-cli",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/mathdroid/igdm-cli.git"
  },
  "scripts": {
    "build": "babel src -d bin",
    "release": "np",
    "release:minor": "release minor"
  },
  "version": "0.5.3"
}

and open terminal npm install or npm update. Easy