Skip to content

Update Mahjong Soul authorisation instructions #37

@jbirch

Description

@jbirch

A few weeks back, Mahjong Soul changed at least their English server to be a centralised login. As such, there are no more POST requests with uid/token parameters.

It seems like the authentication is still token-based. For example, on login is a POST made to https://en-sdk-api.yostarplat.com/user/quick-login with the following Authorization header:

{
  "Head": {
    "Region":"US",
    "PID":"US-MAJONGSOUL", 
    ... ,
    "DeviceID":"...",
    "UID":"...",
    "Token":"...",
    ...
  },
  "Sign":"..."
}

However, if I naively attempt to use the values of UID and Token as ms_uid and ms_token, I'll get a protobuf reflection error that is presumably really a "There was an error response on heartbeat because your credentials are bad actually".

$ python main.py -m both 'https://mahjongsoul.game.yo-star.com/?paipu=...'
Traceback (most recent call last):
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/injustice_judge/fetch/majsoul.py", line 172, in fetch_majsoul
    f = open(f"cached_games/game-{identifier}.log", 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'cached_games/game-....log'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/main.py", line 124, in <module>
    main()
    ~~~~^^
 .....
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/injustice_judge/fetch/majsoul.py", line 179, in fetch_majsoul
    async with MahjongSoulAPI(mjs_username=os.getenv("ms_username"), mjs_password=os.getenv("ms_password"), mjs_uid=os.getenv("ms_uid"), mjs_token=os.getenv("ms_token")) as api:
               ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/injustice_judge/fetch/majsoul.py", line 45, in __aenter__
    await self.login()
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/injustice_judge/fetch/majsoul.py", line 89, in login
    await self.login_en()
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/injustice_judge/fetch/majsoul.py", line 115, in login_en
    await self.call("heartbeat")
  File "/var/home/jbirch/Workspace/src/github.com/Longhorn-Riichi/InjusticeJudge/injustice_judge/fetch/majsoul.py", line 58, in call
    req: Message = pb.reflection.MakeClass(method.input_type)(**fields)  # type: ignore[attr-defined]
                   ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'google.protobuf.reflection' has no attribute 'MakeClass'

Very possible I've just screwed up my local stuff and these credentials actually do work. Or it might be that they need an additional bit of information, like the device ID or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions