Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support to Resolve MiyousheGeetestError #183

Closed
wants to merge 7 commits into from

Conversation

seriaati
Copy link
Collaborator

Summary

Miyoushe API requests will fail when any request is being sent from an unrecognized device, in a previous commit I implemented a check to raise MiyousheGeetestError if that is the case, but there are currently no ways of resolving those errors with the library.

Here are 3 ways (that I know) to resolve the error.

1. Pass in Device Information (Easiest to Implement)

This requires the user to have a device that is already "trusted", typically a phone that has the Miyoushe app installed and has been logged in with the Miyoushe account for a long period of time. When requesting, pass in the information of that device through the device_fp and device_id headers, and theoretically Miyoushe will think this request is secure and will not raise the error. A possible implementation is to allow users to pass in custom headers during genshin.Client initialization, and the client will use them in all requests.

2. Solve the Geetest and Re-Request (WIP)

This is what I am currently working on, though not quite successful.
The code snippet below is what I plan to implement this solution:

import genshin

client = genshin.Client(...) # Fill in cookies, region, game and any other information
try:
      result = await client.get_genshin_notes()
except genshin.MiyousheGeetestError:
      mmt = await client.create_mmt()
      mmt_result = await server.solve_geetest(mmt, api_server="api.geetest.com", proxy_geetest=True)
      await client.verify_mmt(mmt_result)
      # Re-request
      result = await client.get_genshin_notes(mmt_result=mmt_result)

However, I encountered an unknown error with retcode 10306 and no error message in verify_mmt. So, I'm stuck.

3. Make the Device Become a Trusted Device

There is little information on this yet, but while looking at gsuid_core's code when I'm trying to resolve the error above, I noticed that it seems to be possible to generate random device information and make them become trusted through API requests, I will look more into this. Also, I'm thinking about adding methods to the auth client that generate random device information, but I need to figure out what device_fp, device_id, and x-rpc-device_id are.

Side Notes

We don't necessarily need to implement all 3 solutions, in fact any one of them being implemented should be enough for the user.

Task List

  • Pass in Device Information
  • Solve the Geetest and Re-Request
  • Make the Device Become a Trusted Device

@seriaati seriaati closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant