[instagram] disable login with username&password (#756)

This commit is contained in:
Mike Fährmann
2020-05-29 23:29:40 +02:00
parent a32aea41e1
commit 3e0848a482
5 changed files with 7 additions and 34 deletions

View File

@@ -10,7 +10,7 @@
"""Extractors for https://www.instagram.com/"""
from .common import Extractor, Message
from .. import text, exception
from .. import text
from ..cache import cache
import itertools
import json
@@ -66,35 +66,10 @@ class InstagramExtractor(Extractor):
@cache(maxage=360*24*3600, keyarg=1)
def _login_impl(self, username, password):
self.log.info("Logging in as %s", username)
page = self.request(self.root + "/accounts/login/").text
headers = {
"Referer" : self.root + "/accounts/login/",
"X-IG-App-ID" : "936619743392459",
"X-Requested-With": "XMLHttpRequest",
}
response = self.request(self.root + "/web/__mid/", headers=headers)
headers["X-CSRFToken"] = response.cookies["csrftoken"]
headers["X-Instagram-AJAX"] = text.extract(
page, '"rollout_hash":"', '"')[0]
url = self.root + "/accounts/login/ajax/"
data = {
"username" : username,
"password" : password,
"queryParams" : "{}",
"optIntoOneTap": "true",
}
response = self.request(url, method="POST", headers=headers, data=data)
if not response.json().get("authenticated"):
raise exception.AuthenticationError()
return {
key: self.session.cookies.get(key)
for key in ("sessionid", "mid", "csrftoken")
}
self.log.warning(
'Logging in with username and password is currently not possible. '
'Use cookies from your browser session instead.')
return {}
def _request_graphql(self, variables, query_hash, csrf=None):
headers = {