Skip to content

Instantly share code, notes, and snippets.

@ctian1
Forked from Luc1412/auth_flow.py
Created January 5, 2021 02:16
Show Gist options
  • Select an option

  • Save ctian1/a249604f9143741bd76e45133b5e1de8 to your computer and use it in GitHub Desktop.

Select an option

Save ctian1/a249604f9143741bd76e45133b5e1de8 to your computer and use it in GitHub Desktop.

Revisions

  1. @Luc1412 Luc1412 revised this gist Apr 18, 2020. 1 changed file with 10 additions and 15 deletions.
    25 changes: 10 additions & 15 deletions auth_flow.py
    Original file line number Diff line number Diff line change
    @@ -1,55 +1,50 @@
    import re
    import aiohttp

    async def run():
    async def run(username, password):
    session = aiohttp.ClientSession()
    data = {
    'client_id': 'play-valorant-web-prod',
    'nonce': '1',
    'redirect_uri': 'https://beta.playvalorant.com/opt_in',
    'response_type': 'token id_token',
    }
    async with session.post('https://auth.riotgames.com/api/v1/authorization', json=data) as r:
    print(r.status)
    print(await r.text())
    await session.post('https://auth.riotgames.com/api/v1/authorization', json=data)

    data = {
    'type': 'auth',
    'username': '',
    'password': ''
    'username': username,
    'password': password
    }
    print(session.cookie_jar)
    async with session.put('https://auth.riotgames.com/api/v1/authorization', json=data) as r:
    print(r.status)
    data = await r.json()
    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)
    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:
    print(r.status)
    data = await r.json()
    entitlements_token = data['entitlements_token']
    print(entitlements_token)
    print('Entitlements Token: ' + entitlements_token)

    async with session.post('https://auth.riotgames.com/userinfo', headers=headers, json={}) as r:
    print(r.status)
    data = await r.json()
    user_id = data['sub']
    print(user_id)
    print('User ID: ' + user_id)
    headers['X-Riot-Entitlements-JWT'] = entitlements_token

    # Example Request. (Access Token and Entitlements Token needs to be included!)
    async with session.get(f'https://pd.eu.a.pvp.net/match-history/v1/history/{user_id}?startIndex=0&endIndex=10', headers=headers) as r:
    print(r.status)
    data = json.loads(await r.text())
    print(data)

    await session.close()

    if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(run())
    asyncio.get_event_loop().run_until_complete(run('exmaple user name', 'my_secret_password'))
  2. @Luc1412 Luc1412 revised this gist Apr 18, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions auth_flow.py
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@
    import re
    import
    import aiohttp

    async def run():
    session = aiohttp.ClientSession()
    #{"client_id":"play-valorant-web-prod","nonce":"ODMsMjE3LDE4Miwx","prompt":"login","redirect_uri":"https://beta.playvalorant.com/opt_in","response_type":"token id_token","scope":"account openid","state":"bG9naW4=","ui_locales":"en-us"}
    data = {
    'client_id': 'play-valorant-web-prod',
    'nonce': '1',
  3. @Luc1412 Luc1412 revised this gist Apr 18, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions auth_flow.py
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,8 @@ async def run():

    data = {
    'type': 'auth',
    'username': 'Luc1412',
    'password': '7obbkjCWlvjXOoO2bn3@'
    'username': '',
    'password': ''
    }
    print(session.cookie_jar)
    async with session.put('https://auth.riotgames.com/api/v1/authorization', json=data) as r:
  4. @Luc1412 Luc1412 revised this gist Apr 18, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion auth_flow.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    import re
    import

    async def run():
    session = aiohttp.ClientSession()
    #{"client_id":"play-valorant-web-prod","nonce":"ODMsMjE3LDE4Miwx","prompt":"login","redirect_uri":"https://beta.playvalorant.com/opt_in","response_type":"token id_token","scope":"account openid","state":"bG9naW4=","ui_locales":"en-us"}
    @@ -11,7 +14,6 @@ async def run():
    print(r.status)
    print(await r.text())

    # {"type":"auth","username":"Luc1412","password":"7obbkjCWlvjXOoO2bn3@","remember":true,"language":"en_US"}
    data = {
    'type': 'auth',
    'username': 'Luc1412',
  5. @Luc1412 Luc1412 created this gist Apr 18, 2020.
    54 changes: 54 additions & 0 deletions auth_flow.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    async def run():
    session = aiohttp.ClientSession()
    #{"client_id":"play-valorant-web-prod","nonce":"ODMsMjE3LDE4Miwx","prompt":"login","redirect_uri":"https://beta.playvalorant.com/opt_in","response_type":"token id_token","scope":"account openid","state":"bG9naW4=","ui_locales":"en-us"}
    data = {
    'client_id': 'play-valorant-web-prod',
    'nonce': '1',
    'redirect_uri': 'https://beta.playvalorant.com/opt_in',
    'response_type': 'token id_token',
    }
    async with session.post('https://auth.riotgames.com/api/v1/authorization', json=data) as r:
    print(r.status)
    print(await r.text())

    # {"type":"auth","username":"Luc1412","password":"7obbkjCWlvjXOoO2bn3@","remember":true,"language":"en_US"}
    data = {
    'type': 'auth',
    'username': 'Luc1412',
    'password': '7obbkjCWlvjXOoO2bn3@'
    }
    print(session.cookie_jar)
    async with session.put('https://auth.riotgames.com/api/v1/authorization', json=data) as r:
    print(r.status)
    data = await r.json()
    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)
    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:
    print(r.status)
    data = await r.json()
    entitlements_token = data['entitlements_token']
    print(entitlements_token)

    async with session.post('https://auth.riotgames.com/userinfo', headers=headers, json={}) as r:
    print(r.status)
    data = await r.json()
    user_id = data['sub']
    print(user_id)
    headers['X-Riot-Entitlements-JWT'] = entitlements_token
    async with session.get(f'https://pd.eu.a.pvp.net/match-history/v1/history/{user_id}?startIndex=0&endIndex=10', headers=headers) as r:
    print(r.status)
    data = json.loads(await r.text())
    print(data)

    await session.close()

    if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(run())