-
Notifications
You must be signed in to change notification settings - Fork 2
/
auth.py
34 lines (28 loc) · 969 Bytes
/
auth.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
import os
import json
from osu import AuthHandler, Scope
CLIENT_ID = int(os.getenv("CLIENT_ID"))
CLIENT_SECRET = os.getenv("CLIENT_SECRET")
REDIRECT_URI = os.getenv("REDIRECT_URI")
DEV_CLIENT_ID = int(os.getenv("DEV_CLIENT_ID"))
DEV_CLIENT_SECRET = os.getenv("DEV_CLIENT_SECRET")
DEV_REDIRECT_URI = os.getenv("DEV_REDIRECT_URI")
auth = AuthHandler(
CLIENT_ID,
CLIENT_SECRET,
REDIRECT_URI,
Scope("public", "identify", "friends.read"),
)
auth.get_auth_token(input(f"{auth.get_auth_url()}\nCode: "))
with open("tests/auth.json", "w") as f:
json.dump(auth.get_save_data(), f)
auth = AuthHandler(
DEV_CLIENT_ID,
DEV_CLIENT_SECRET,
DEV_REDIRECT_URI,
Scope("public", "identify", "friends.read", "forum.write", "chat.read", "chat.write", "chat.write_manage")
)
auth.set_domain("dev.ppy.sh")
auth.get_auth_token(input(f"{auth.get_auth_url()}\nCode: "))
with open("tests/dev-auth.json", "w") as f:
json.dump(auth.get_save_data(), f)