mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 07:10:09 -07:00
Generate OAuth URL
This commit is contained in:
parent
7cd0ce0ff1
commit
e053521bc5
32
wideq.py
32
wideq.py
@ -1,21 +1,45 @@
|
||||
import requests
|
||||
from urllib.parse import urljoin, urlencode
|
||||
|
||||
|
||||
GATEWAY_URL = 'https://kic.lgthinq.com:46030/api/common/gatewayUriList'
|
||||
APP_KEY = 'wideq'
|
||||
SECURITY_KEY = 'nuts_securitykey'
|
||||
DATA_ROOT = 'lgedmRoot'
|
||||
COUNTRY = 'US'
|
||||
LANGUAGE = 'en-US'
|
||||
OAUTH_PATH = '/login/sign_in'
|
||||
SVC_CODE = 'SVC202'
|
||||
CLIENT_ID = 'LGAO221A02'
|
||||
|
||||
|
||||
def gateway_info(country='US', lang='en-US'):
|
||||
req_data = {DATA_ROOT: {'countryCode': country, 'langCode': lang}}
|
||||
def gateway_info():
|
||||
req_data = {DATA_ROOT: {'countryCode': COUNTRY, 'langCode': LANGUAGE}}
|
||||
headers = {
|
||||
'x-thinq-application-key': APP_KEY,
|
||||
'x-thinq-security-key': SECURITY_KEY,
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
res = requests.post(GATEWAY_URL, json=req_data, headers=headers)
|
||||
return res.json()
|
||||
return res.json()[DATA_ROOT]
|
||||
|
||||
|
||||
def oauth_url(oauth_base):
|
||||
url = urljoin(oauth_base, OAUTH_PATH)
|
||||
query = urlencode({
|
||||
'country': COUNTRY,
|
||||
'language': LANGUAGE,
|
||||
'svcCode': SVC_CODE,
|
||||
'authSvr': 'oauth2',
|
||||
'client_id': CLIENT_ID,
|
||||
'division': 'ha',
|
||||
'grant_type': 'password',
|
||||
})
|
||||
return '{}?{}'.format(url, query)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(gateway_info())
|
||||
gw = gateway_info()
|
||||
oauth_base = gw['empUri']
|
||||
api_root = gw['thinqUri']
|
||||
print(oauth_url(oauth_base))
|
||||
|
Loading…
x
Reference in New Issue
Block a user