-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRSO_Auth.py
More file actions
37 lines (33 loc) · 1.31 KB
/
RSO_Auth.py
File metadata and controls
37 lines (33 loc) · 1.31 KB
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
import re, aiohttp, asyncio, json
async def auth(username, password):
session = aiohttp.ClientSession()
data = {
'client_id': 'play-valorant-web-prod',
'nonce': '1',
'redirect_uri': 'https://playvalorant.com/opt_in',
'response_type': 'token id_token',
}
await session.post('https://auth.riotgames.com/api/v1/authorization', json=data)
data = {
'type': 'auth',
'username': username,
'password': password
}
async with session.put('https://auth.riotgames.com/api/v1/authorization', json=data) as r:
data = await r.json()
#print(data)
pattern = re.compile('access_token=((?:[a-zA-Z]|\d|\.|-|_)*).*id_token=((?:[a-zA-Z]|\d|\.|-|_)*).*expires_in=(\d*)')
data = pattern.findall(data['response']['parameters']['uri'])[0]
access_token = data[0]
#print('Access Token: ' + access_token)
id_token = data[1]
expires_in = data[2]
headers = {
'Authorization': f'Bearer {access_token}',
}
async with session.post('https://entitlements.auth.riotgames.com/api/token/v1', headers=headers, json={}) as r:
data = await r.json()
entitlements_token = data['entitlements_token']
#print('Entitlements Token: ' + entitlements_token)
await session.close()
return (access_token, entitlements_token)