mautrix / instagram

A Matrix-Instagram DM puppeting bridge
https://matrix.to/#/#instagram:maunium.net
GNU Affero General Public License v3.0
144 stars 28 forks source link

Attempt to decode JSON with unexpected mimetype #8

Open gruberdev opened 3 years ago

gruberdev commented 3 years ago

Expected Behavior

A normal login process

Current Behavior

When I try to type login myusername mypassword, I get in return as a answer from the bot: Unhandled error while handling command:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mautrix/bridge/commands/handler.py", line 405, in handle
    await self._run_handler(handler, evt)
  File "/usr/lib/python3.8/site-packages/mautrix/bridge/commands/handler.py", line 290, in __call__
    return await self._handler(evt)
  File "/usr/lib/python3.8/site-packages/mautrix_instagram/commands/auth.py", line 66, in login
    api, state = await get_login_state(evt.sender, username, evt.config["instagram.device_seed"])
  File "/usr/lib/python3.8/site-packages/mautrix_instagram/commands/auth.py", line 46, in get_login_state
    await api.qe_sync_login_experiments()
  File "/opt/mautrix-instagram/mauigpapi/http/qe.py", line 26, in qe_sync_login_experiments
    return await self.__sync(self.state.application.LOGIN_EXPERIMENTS)
  File "/opt/mautrix-instagram/mauigpapi/http/qe.py", line 41, in __sync
    resp = await self.std_http_post("/api/v1/qe/sync/", data=req, response_type=QeSyncResponse)
  File "/opt/mautrix-instagram/mauigpapi/http/base.py", line 121, in std_http_post
    json_data = await self._handle_response(resp)
  File "/opt/mautrix-instagram/mauigpapi/http/base.py", line 143, in _handle_response
    body = await resp.json()
  File "/usr/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1097, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://i.instagram.com/accounts/login/')

Possible Solution

Googling this exact error, I got a few interesting responses:

Steps to Reproduce

  1. Create an account with 2-FA enabled
  2. Fail to properly login
  3. Deactivate 2-FA
  4. Try to log-in again

Environment

Any ideas what could be causing this?

gruberdev commented 3 years ago

Even after deactivating, excluding the container, resetting the database and ensuring everything was connected, I still face a similar issue while logging in:

File "/usr/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1097, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://i.instagram.com/accounts/login/')

Which makes me suspect it may have something to do with my account being linked to my facebook account to OAuth, although I have both username and password through Instagram's interface. I'm not sure what to try next.