SAPikachu / amae-koromo-scripts

Scripts for crawling and processing Majsoul data
MIT License
75 stars 7 forks source link

Question: How to get Majsoul access token? #2

Closed purerosefallen closed 4 years ago

purerosefallen commented 4 years ago

I tried to look through browser console in Majsoul, but found nothing. Thanks for help.

SAPikachu commented 4 years ago

For Chinese server: Access token is one of the GUID stored in localStorage (There is 2 and I forgot which one, so please try both). For Japanese server (email authentication): OAUTH_TYPE must be set to 7, and you need to capture 2 parts of the token from the first or second WebSocket message. They are plaintext, first part is a long hex number and the second part is a smaller decimal number. Token is the 2 numbers joined with -.

I haven't tried the international server so I am not sure how to create a token for it, but since Japanese server is now connected with international server, all match data should be the same and we can just use an account on Japanese server.

carl0967 commented 4 years ago

Could you tell me more about how to get an access token? Does the following mean to capture network packets when logging in with a web browser? For example, using software like Wireshark.

and you need to capture 2 parts of the token from the first or second WebSocket message

I'm trying to connect to an international server (URL_BASE: "https://mahjongsoul.game.yo-star.com/"), but I'm having trouble authenticating because I don't know the access token.

I was planning to connect to the Japanese server (URL_BASE: "https://game.mahjongsoul.com/"), but I gave up because the communication of "service = ws-gateway & protocol = ws & ssl = true" failed with 502.

SAPikachu commented 4 years ago

@carl0967 You can use Chrome to get the token:

  1. Ensure you have logged in and inside the game (I recommend to register a new account for use in the scripts)
  2. Press F12 to open dev tools
  3. Select "Network" tab and "WS" subtab
  4. Refresh the page, wait a bit and the WS connection should appear in the list
  5. Select the connection and select "Messages" tab
  6. Check the first a few messages for the token mentioned in my earlier comment

I was planning to connect to the Japanese server (URL_BASE: "https://game.mahjongsoul.com/"), but I gave up because the communication of "service = ws-gateway & protocol = ws & ssl = true" failed with 502.

Not sure why it doesn't load for you, it should be able to load if Majsoul can load in browser in the same system. Can you paste script output here so that I can look into it?

carl0967 commented 4 years ago

@SAPikachu Thank you! I have successfully authenticated.

I said before that I couldn't connect to the Japanese server, but now I can. So the problem is solved. Thank you.