Skip to main content

migate is a simplified Xiaomi authentication gateway for Python projects

Project description

migate

Xiaomi authentication gateway for Python


Version Changelog


Install

pip install migate

Or add it as a dependency in your project:

# pyproject.toml
dependencies = ["migate"]
# requirements.txt
migate

Usage

import migate

# --- passport (default) ---
# If no params are passed, sid defaults to passport.
# pass_token = migate.get_passtoken()
# service = migate.get_service(pass_token)

# --- unlockApi: bootloader unlock ---
# params = {"sid": "unlockApi", "checkSafeAddress": True}

# --- xiaomiio: Mi Home / smart home devices ---
# params = {"sid": "xiaomiio"}

# --- micoapi: Mi AI speaker ---
# params = {"sid": "micoapi"}

# --- i.mi.com: Mi Cloud / Find Device ---
# params = {"sid": "i.mi.com"}

# --- 18n_bbs_global: Mi Community ---
# params = {"sid": "18n_bbs_global"}

params = {"sid": "unlockApi", "checkSafeAddress": True}

pass_token = migate.get_passtoken(params)
# skip the interactive prompt if already logged in
# pass_token = migate.get_passtoken(params, silent=True)

service = migate.get_service(pass_token, params)

print(pass_token)
# {
#   "deviceId":  "wb_...",
#   "passToken": "...",
#   "userId":    "..."
# }

print(service)
# {
#   "servicedata": {
#     "nonce":     ...,
#     "ssecurity": "...",
#     "cUserId":   "...",
#     "psecurity": "...",
#     "deviceId":  "wb_..."
#   },
#   "cookies": {
#     # passport       -> {}
#     # unlockApi      -> serviceToken, unlockApi_slh, unlockApi_ph, userId
#     # xiaomiio       -> serviceToken, cUserId, userId
#     # micoapi        -> serviceToken, micoapi_slh, micoapi_ph, userId
#     # i.mi.com       -> serviceToken, i.mi.com_slh, i.mi.com_ph, userId
#     # 18n_bbs_global -> serviceToken, popRunToken, new_bbs_serviceToken, new_login, userId
#   }
# }

All functions return None on failure. Always check the return value before passing it to the next call.


Utilities

# get account region 
region = migate.get_region(pass_token)

# get dataCenterZone
## get with account region
zone = migate.get_dataCenterZone(region)                 ## get with account ID 
zone = migate.get_dataCenterZone(userId)                 ## manual selection
zone = migate.get_dataCenterZone()                              

# get uRegion
uRegion = migate.get_uRegion()

# get uLocale
uLocale = migate.get_uLocale() 

# areaConfig, ex: with SG
area = migate.get_areaConfig("SG")
# {"code": "SG", "name": "Singapore", "dial": "+65"}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

migate-1.1.7.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

migate-1.1.7-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file migate-1.1.7.tar.gz.

File metadata

  • Download URL: migate-1.1.7.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for migate-1.1.7.tar.gz
Algorithm Hash digest
SHA256 33370a38b4f0d3391849ba50bd03a4b9baa0e139cb95c059448ab0dcf6e44f68
MD5 fc8921b56e8607cc0379586dc6a89887
BLAKE2b-256 d90f30e68674786c0b9d1b68d3fb939290face01d8d3f6c92d4bbde3fcb8ae36

See more details on using hashes here.

File details

Details for the file migate-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: migate-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for migate-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f449d961aa6f92796d8f9980bcab5e0c2b93f22ed46cbc76d257198ea5dd8d91
MD5 76d5012efcff6771658f03bfd460f697
BLAKE2b-256 ab1bd4ded0fb825762ce80f5e966efe50cf444e8e8bf64025a212a3ebf577a4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page