-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatesecret.py
41 lines (30 loc) · 1.13 KB
/
createsecret.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
39
40
41
#!/usr/bin/env python3
import getpass
from mastodon import Mastodon
INSTANCE = "https://botsin.space"
def create_app_secret():
client_id, client_secret = Mastodon.create_app(
"openbsd-commits-to-mastodon", api_base_url=INSTANCE
)
return client_id, client_secret
def create_login_secret(client_id, client_secret, email, password):
mastodon = Mastodon(
client_id=client_id, client_secret=client_secret, api_base_url=INSTANCE
)
access_token = mastodon.log_in(email, password)
return access_token
def main():
email = input("email address: ")
password = getpass.getpass()
client_id, client_secret = create_app_secret()
access_token = create_login_secret(client_id, client_secret, email, password)
print(
"INSERT INTO credentials (account, client_id, client_secret, access_token) "
f"VALUES ('{email}', '{client_id}', '{client_secret}', '{access_token}');"
)
print(
f"UPDATE credentials SET client_id='{client_id}', client_secret="
f"'{client_secret}', access_token='{access_token}' WHERE account='{email}';"
)
if __name__ == "__main__":
main()