I currently have this code:
import requests
headers = {
'Accept': 'application/json',
'Authorization': 'Basic cmlvdDp4MFVua3NrcFMzSUlaTkd6TVlaaVNn',
}
res = requests.get('https://127.0.0.1:52351/lol-champ-select/v1/session', headers=headers)
print(res.json())
My problem is that no matter what I do, I'm getting this error:
Traceback (most recent call last):
File "clientTest.py", line 8, in <module>
res = requests.get('https://127.0.0.1:52351/lol-champ-select/v1/session', headers=headers)
File "C:\Users\Dimitrie\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Dimitrie\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Dimitrie\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Dimitrie\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Dimitrie\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=52351): Max retries exceeded with url: /lol-champ-select/v1/session (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))
Clearly I'm doing something wrong, however I'm not quite sure what the problem is. It sounds like there is something wrong with my authentication token I copied and pasted out of Rift Explorer. However, I'm not really sure what the role of this token is considering everything is handled over localhost. I'm also not sure how to acquire this token. Could anyone offer some help?
Edit: Okay, so it turns out my problem was SSL verification built into python's requests library. I fixed it by changing the request line to this:
res = requests.get('https://127.0.0.1:52351/lol-champ-select/v1/session', headers=headers, verify=False)
However, I still have no idea how to get my Authorization key and the randomized port after the client starts. How do I do that?
Edit 2:
Wow so this was absurdly complicated to figure out. Doesn't help that there is no documentation anywhere. Here's how I solved it:
When the League Client starts, a file called "lockfile" is generated in the League of Legends install directory. The file looks something like this:
LeagueClient:9872:52351:x0UnkskpS3IIZNGzMYZiSg:https
In my case, 52351 is the port. To find the authentication token, you must take "x0UnkskpS3IIZNGzMYZiSg" and concatenate it with "riot:" with the riot part first. Like this:
"riot:x0UnkskpS3IIZNGzMYZiSg"
You then need to take this string and encode it. Then you must take that encoding and turn it into base 64 as a string. That finally is your authentication token. This is the code I used to compute it in python.
merged = "riot:" + "x0UnkskpS3IIZNGzMYZiSg"
authToken = base64.b64encode(merged.encode())
I hope this helps someone else because it took me a good few hours of struggling.