Skip to content

Commit

Permalink
For the same import, using the same device id
Browse files Browse the repository at this point in the history
  • Loading branch information
qqaatw committed May 1, 2022
1 parent aca1890 commit b224d07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Taipower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import asyncio
import sys
import uuid


DEVICE_ID = str(uuid.uuid4())

if sys.platform == "win32": # https://stackoverflow.com/questions/61543406/asyncio-run-runtimeerror-event-loop-is-closed
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
5 changes: 2 additions & 3 deletions Taipower/connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import uuid
import json
import logging
import time
Expand All @@ -7,7 +6,7 @@
from datetime import datetime

import httpx
from . import utility
from . import DEVICE_ID, utility

ENDPOINT = "mapp-2019.taipower.com.tw"
BASIC_AUTH = "dHBlYy13U1pvLTVDNjZTZG84ZzM6X1UyVlpZd05kWi1hTW9ILV9fZlctZ3ROR0lwVmgydy4="
Expand Down Expand Up @@ -150,7 +149,7 @@ def login(self, use_refresh_token=False):
"password": utility.des_encrypt(self._password),
"grant_type": "password",
"scope": "tpec",
"device_id": str(uuid.uuid4()),
"device_id": DEVICE_ID,
"appVersion": APP_VERSION,
}

Expand Down

0 comments on commit b224d07

Please sign in to comment.