Skip to content

Commit

Permalink
Updated token, added instructions to update token manually
Browse files Browse the repository at this point in the history
  • Loading branch information
FLAK-ZOSO committed Dec 14, 2023
1 parent 29c79d7 commit 98665a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ Other features may be added in the future.
git clone https://github.com/FLAK-ZOSO/OliCyberUCT
```

Consider putting your user token in `token.txt` if you receive the following error.

```py
Traceback (most recent call last):
File "/home/flak-zoso/Documents/GitHub/OliCyberUCT/playerdiff.py", line 12, in <module>
user1.get_stats()
File "/home/flak-zoso/Documents/GitHub/OliCyberUCT/olicybertools.py", line 13, in get_stats
if self.stats["extended"]:
TypeError: 'NoneType' object is not subscriptable
```

You can find your user token by logging in to `training.olicyber.it` and looking at the localStorage in your browser's developer tools.

```js
console.log(localStorage.getItem("token"));
```

## Usage

```md
Expand Down
5 changes: 3 additions & 2 deletions olicybertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations
import requests
import typing
session = requests.Session()


class User:
Expand Down Expand Up @@ -53,10 +54,10 @@ def fetch_user_stats(user_id: int, debug: bool=False) -> dict:
"accept": "application/json",
"authority": "training.olicyber.it",
"accept-language": "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7",
"authorization": "Token 2a499b3a-e3d8-479e-b8a9-b3de126bd098",
"authorization": f"Token {open('token.txt').read().strip()}",
"Referer": f"https://training.olicyber.it/player/{user_id}"
}
response = requests.get(
response = session.get(
f"https://training.olicyber.it/api/scoreboard/player/{user_id}",
headers=headers
)
Expand Down
1 change: 1 addition & 0 deletions token.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
46733a53-f4b1-4c50-ac34-fd95a525b506

0 comments on commit 98665a2

Please sign in to comment.