Add account login function
This commit is contained in:
parent
5c65cab619
commit
cdfd3619f0
2 changed files with 20 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
|
/accounts
|
||||||
*.json
|
*.json
|
||||||
|
|
19
login.py
Normal file
19
login.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from mastodon import Mastodon
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
username = input("username: ")
|
||||||
|
name = input("application name: ")
|
||||||
|
url = input("server url: ")
|
||||||
|
|
||||||
|
if os.path.exists("accounts") and not os.path.isdir("accounts"):
|
||||||
|
print("accounts exists but isn't a directory")
|
||||||
|
exit(2)
|
||||||
|
elif not os.path.exists("accounts"):
|
||||||
|
os.mkdir("accounts")
|
||||||
|
|
||||||
|
Mastodon.create_app(name, to_file=f"accounts/{username}.client.secret", api_base_url=url, user_agent="fedifeeds")
|
||||||
|
masto = Mastodon(f"accounts/{username}.client.secret")
|
||||||
|
print(masto.auth_request_url())
|
||||||
|
masto.log_in(username, code=input("code: "), to_file=f"accounts/{username}.secret")
|
Loading…
Reference in a new issue