Skip to content

401 Error / Cannot retrieve Authorization header - Did Monarch change their auth? #14

Description

@n-shay

Container started failing with the error below a week ago.

I only had the time to take a look tonight and my initial thought was the my token expired. I noticed I was logged out of browser session as well (both web app and retail purchace sync chrome extension).

The API calls from the monarch app no longer have Authorization header, it seems like they switched to a session cookie.

Anyone else experiencing the same?

2026-05-15 03:06:29,810 ERROR studentaid_monarch_sync - Wrote debug bundle: data/debug_bundle_cri_20260515_030629.zip
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gql/transport/aiohttp.py", line 273, in _raise_transport_server_error_if_status_more_than_400
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/client_reqrep.py", line 636, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url='https://api.monarch.com/graphql'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/src/studentaid_monarch_sync/cli.py", line 550, in _preflight_monarch
    accounts = await mc.list_accounts()  # forces an authenticated API call
  File "/app/src/studentaid_monarch_sync/monarch/client.py", line 162, in list_accounts
    resp = await self._call_with_retry("get_accounts", lambda: self._mm.get_accounts())
  File "/app/src/studentaid_monarch_sync/monarch/client.py", line 85, in _call_with_retry
    return await fn()
  File "/usr/local/lib/python3.10/dist-packages/monarchmoney/monarchmoney.py", line 254, in get_accounts
    return await self.gql_call(
  File "/usr/local/lib/python3.10/dist-packages/monarchmoney/monarchmoney.py", line 2936, in gql_call
    return await self._get_graphql_client().execute_async(
  File "/usr/local/lib/python3.10/dist-packages/gql/client.py", line 352, in execute_async
    return await session.execute(
  File "/usr/local/lib/python3.10/dist-packages/gql/client.py", line 1567, in execute
    result = await self._execute(
  File "/usr/local/lib/python3.10/dist-packages/gql/client.py", line 1490, in _execute
    result = await self.transport.execute(
  File "/usr/local/lib/python3.10/dist-packages/gql/transport/aiohttp.py", line 381, in execute
    return await self._prepare_result(resp)
  File "/usr/local/lib/python3.10/dist-packages/gql/transport/aiohttp.py", line 322, in _prepare_result
    await self._raise_response_error(
  File "/usr/local/lib/python3.10/dist-packages/gql/transport/aiohttp.py", line 286, in _raise_response_error
    cls._raise_transport_server_error_if_status_more_than_400(resp)
  File "/usr/local/lib/python3.10/dist-packages/gql/transport/aiohttp.py", line 275, in _raise_transport_server_error_if_status_more_than_400
    raise TransportServerError(str(e), e.status) from e
gql.transport.exceptions.TransportServerError: 401, message='Unauthorized', url='https://api.monarch.com/graphql'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/src/studentaid_monarch_sync/__main__.py", line 5, in <module>
    raise SystemExit(main())
  File "/app/src/studentaid_monarch_sync/cli.py", line 291, in main
    asyncio.run(_preflight_monarch(cfg, check_mappings=not bool(args.auto_setup_accounts)))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/app/src/studentaid_monarch_sync/cli.py", line 565, in _preflight_monarch
    raise RuntimeError(
RuntimeError: Monarch preflight failed. This often means your MONARCH_TOKEN/session is invalid/expired, or your loan account mappings are missing/wrong. Fix Monarch auth (or delete data/monarch_session.pickle), then run `studentaid_monarch_sync setup-monarch-accounts --apply` to auto-create/map accounts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions