-
Notifications
You must be signed in to change notification settings - Fork 14
/
generate.py
38 lines (32 loc) · 1.09 KB
/
generate.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
35
36
37
38
import asyncio
import json
from constants import CLIENT_SECRET, CLIENT_ID, INITIAL_BIO, INITIAL_TOKEN
from aiohttp import ClientSession
body = {
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
"grant_type": "authorization_code",
"redirect_uri": "http://localhost:1234/callback",
"code": INITIAL_TOKEN,
}
async def generate():
async with ClientSession() as session:
async with session.post(
"https://accounts.spotify.com/api/token", data=body
) as post_response:
save = await post_response.json()
to_create = {
"bio": INITIAL_BIO,
"access_token": save["access_token"],
"refresh_token": save["refresh_token"],
"telegram_spam": False,
"spotify_spam": False,
}
with open("./database.json", "w") as outfile:
json.dump(to_create, outfile, indent=4, sort_keys=True)
def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(generate())
loop.close()
if __name__ == '__main__':
main()