Global-device helper scripts for Xiaomi Community unlock request timing (HyperOS 1/2/3), including token collection helpers for Windows and Linux.
- Thanks to @dotKin
- Thanks to @nicogrimaldi (translation)
- Thanks to @redmugen (detailed guidance)
- Thanks to @bybestix (GetTokens updates/hotfix)
- Linux GetTokens variant thanks to @Jenna-66
- Works with global devices and HyperOS 1/2/3 (including devices released with HyperOS 3).
- The Xiaomi Community app status can be misleading during this process.
- This workflow is intended to reduce quota-limit failures when sending unlock requests.
- Use desktop tools only: Chrome, Firefox, PowerShell/Terminal, Python.
- Do not use Windows mobile apps for this process.
- Run network diagnostics as Administrator when using Ping.bat.
- NScript.py: main request-timing script.
- GetTokens.py: Windows token helper (automates login flow + token.txt + 4 script windows).
- gettokens_linux.py: Linux/GNOME token helper (same idea as Windows helper).
- token.txt: token slots used by NScript.py (rows 1-4).
- timeshift.txt: timing offsets used by NScript.py.
- Ping.bat: quick connectivity/packet-loss checks for NTP/Mi endpoints.
- Python 3 installed and available in PATH.
- Firefox installed.
- Chrome installed.
- Stable internet connection (VPN to US only if Xiaomi pages fail).
- Open terminal in this folder.
- Run:
py GetTokens.py- When prompted, provide the script path/name to run (for this repo use NScript.py).
- Log in on Firefox when asked, then press OK.
- Log in on Chrome when asked, then press OK.
- The script writes token.txt automatically and opens 4 windows for NScript.py (rows 1-4).
- Open terminal in this folder.
- Run:
python3 gettokens_linux.py- Log in on Firefox when asked, then press OK.
- The script reads Firefox and Chrome cookies directly (no WebDriver required). It also supports Chromium-family browsers on Linux (Thorium, Chromium, Brave, Edge, Opera) for token retry/open steps.
- If Chrome token is not found automatically, it opens a fallback login retry and allows manual token paste.
- The script writes token.txt automatically and opens 4 terminals for NScript.py (rows 1-4).
Use this only if automatic token scripts do not work.
- In Firefox, log in to Xiaomi Community using one of:
-
Get cookie new_bbs_serviceToken from Firefox (Cookie Editor or equivalent).
-
Put this token into rows 1 and 3 of token.txt.
-
In Chrome, log in to Xiaomi Community and run this in the URL bar:
javascript:(function(){var token=document.cookie.match(/popRunToken=([^;]+)/);if(token){prompt("Copy the token:", token[1]);}else{alert("Token not found");}})()- Put this token into rows 2 and 4 of token.txt.
You can also run manually in separate terminals:
python3 NScript.pyWhen prompted for token row number, run rows 1, 2, 3, and 4 in separate windows.
After script execution, always do this on the phone:
- Settings -> Mi Account -> Sign out.
- Reboot device.
- Sign in again.
- Settings -> Additional/Advanced settings -> Developer options -> Mi Unlock Status.
- Link account to device.
- Attempt unlock with Mi Unlock tool.
If account linking succeeds, enable OEM unlock and continue with Mi Unlock.
If requests fail or timeout frequently, run Ping.bat as Administrator and verify packet loss/latency to listed hosts.
- L1: https://c.mi.com/global/
- L2: https://new.c.mi.com/global/
- L3: https://xiaomitools.com/download/mi-unlock-tool-v7-6-727-43/
- If L1/L2 do not load, try a VPN endpoint in the United States.
- Refresh tokens shortly before use (recommended within 30 minutes).
- Keep all script windows open until around 00:00 China time.
- If the script name changes in future versions, provide the updated file name/path when GetTokens.py asks.
Use these scripts responsibly and only on devices/accounts you own or are authorized to manage. You are responsible for compliance with Xiaomi policies and local laws.