PaiGram/utils/genshin.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
569 B
Python
Raw Normal View History

2022-12-10 12:37:43 +00:00
from typing import Optional
from genshin import Client
from genshin.utility import recognize_genshin_server
AUTHKEY_API = "https://api-takumi.mihoyo.com/binding/api/genAuthKey"
async def get_authkey_by_stoken(client: Client) -> Optional[str]:
"""通过 stoken 获取 authkey"""
json = {
"auth_appid": "webview_gacha",
"game_biz": "hk4e_cn",
"game_uid": client.uid,
"region": recognize_genshin_server(client.uid),
}
data = await client.request_bbs(AUTHKEY_API, method="POST", data=json)
return data.get("authkey")