-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.py
43 lines (34 loc) · 1.08 KB
/
login.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import requests
# Login by phone and password
def login(phone, pwd):
login_url = "https://as.hypergryph.com/user/auth/v1/token_by_phone_password"
data = {"phone": phone, "password": pwd}
res = requests.post(login_url, data=data)
if res.status_code != 200:
raise Exception('Login failed')
return res.json()['data']['token']
# User information
def user_info(token):
user_url = 'https://as.hypergryph.com/u8/user/info/v1/basic'
data = {
"appId": 1,
"channelMasterId": 1,
"channelToken": {
'token': token
},
}
res = requests.post(user_url, json=data)
if res.status_code != 200:
raise Exception('Get user info failed')
account = {
'uid': res.json()['data']['uid'],
'nickName': res.json()['data']['nickName'],
}
return account
# Get token by cookie
def token_api(cookie):
token_url = "https://web-api.hypergryph.com/account/info/hg"
header = {'cookie': cookie}
res = requests.get(token_url, headers=header)
token = res.json()['data']['content']
return token