dvingerh / PyInstaStories

Python script to download Instagram stories from Instagram users.
MIT License
329 stars 74 forks source link

Authentification failed #17

Closed thelele closed 5 years ago

thelele commented 5 years ago

I'm on windows, when I try to download a stories I get this error, and then when I go on instagram it says that somebody tried to connect to your account, I click on "it was me" but still when I redo the command line I have the same error.

----------------------------------------------------------------------
[I] PYINSTASTORIES (SCRIPT V2.1 - PYTHON V3.5.2) - 04:02:50 PM
----------------------------------------------------------------------
[W] Unable to find auth cookie file: credentials.json (creating a new one...)
[E] Client Error: {"error_type": "checkpoint_challenge_required", "message": "challenge_required", "challenge": {"url": "https://i.inst
agram.com/challenge/xxx/xxxx/", "logout": false, "api_path": "/challenge/xxx/xxx/", "hide_webview_header": t
rue, "lock": true, "native_flow": true}, "status": "fail"}
----------------------------------------------------------------------
dvingerh commented 5 years ago

See https://github.com/notcammy/PyInstaStories/issues/15

thelele commented 5 years ago

Thanks, will try to create a new account then.

123aezakmi123 commented 5 years ago

Temporary fix: Login from web browser and get the sessionid cookie (DO NOT LOG OUT) Edit the login function as i did (paste the correct cookie)

P.S. Does the softban go away after a while (how many days?) or is it permanent?


def login(username=username, password=password):
    device_id = None
    try:
        settings_file = "credentials.json"
        if not os.path.isfile(settings_file):
            # settings file does not exist
            print('[W] Unable to find auth cookie file: {0!s} (creating a new one...)'.format(settings_file))

            # login new
            api = Client(
            username, password,
            on_login=lambda x: onlogin_callback(x, settings_file))

            #################   WORKAROUND  #################
            for cookie in api.cookie_jar:
                if cookie.name == "sessionid":
                    cookie.value = "XXXXXX%XXXXXXX%XXXXXX"
            #################   WORKAROUND  #################
        else:
            with open(settings_file) as file_data:
                cached_settings = json.load(file_data, object_hook=from_json)

            device_id = cached_settings.get('device_id')
            # reuse auth settings
            api = Client(
                username, password,
                settings=cached_settings)

            #################   WORKAROUND  #################
            for cookie in api.cookie_jar:
                if cookie.name == "sessionid":
                    cookie.value = "XXXXXX%XXXXXXX%XXXXXX"
            #################   WORKAROUND  #################

        print('[I] Using cached login cookie for "' + api.authenticated_user_name + '".')
dvingerh commented 5 years ago

@123aezakmi123 I'll take a look at your snippet over the weekend, thanks for the info. I don't know anything about softbans.

beakwood commented 4 years ago

Temporary fix: Login from web browser and get the sessionid cookie (DO NOT LOG OUT) Edit the login function as i did (paste the correct cookie)

P.S. Does the softban go away after a while (how many days?) or is it permanent?

def login(username=username, password=password):
  device_id = None
  try:
      settings_file = "credentials.json"
      if not os.path.isfile(settings_file):
          # settings file does not exist
          print('[W] Unable to find auth cookie file: {0!s} (creating a new one...)'.format(settings_file))

          # login new
          api = Client(
          username, password,
          on_login=lambda x: onlogin_callback(x, settings_file))

          #################   WORKAROUND  #################
          for cookie in api.cookie_jar:
              if cookie.name == "sessionid":
                  cookie.value = "XXXXXX%XXXXXXX%XXXXXX"
          #################   WORKAROUND  #################
      else:
          with open(settings_file) as file_data:
              cached_settings = json.load(file_data, object_hook=from_json)

          device_id = cached_settings.get('device_id')
          # reuse auth settings
          api = Client(
              username, password,
              settings=cached_settings)

          #################   WORKAROUND  #################
          for cookie in api.cookie_jar:
              if cookie.name == "sessionid":
                  cookie.value = "XXXXXX%XXXXXXX%XXXXXX"
          #################   WORKAROUND  #################

      print('[I] Using cached login cookie for "' + api.authenticated_user_name + '".')

Where would I go to edit this ? What is the file with login function and where about do I edit this into? the auth.py?

123aezakmi123 commented 4 years ago

@beakwood in pyinstastories.py file search for def login and replace the entire code posted here https://github.com/notcammy/PyInstaStories/issues/17#issuecomment-501285963

OTHER FIX I solved the challenge_required error enabling the 2FA and disabling it

afterdelight commented 4 years ago

@123aezakmi123 I tried the code and the 2fA solution but both didn't work.

dvingerh commented 4 years ago

@123aezakmi123 I tried the code and the 2fA solution but both didn't work.

See both https://github.com/dvingerh/PyInstaLive/issues/57#issuecomment-616072063 and https://github.com/dvingerh/PyInstaLive/issues/57#issuecomment-524650248

afterdelight commented 4 years ago

It worked, it didn't even ask for challenge codes anymore, thanks !