diff --git a/.gitignore b/.gitignore index a6c57f5..f34e9d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +/accounts *.json diff --git a/login.py b/login.py new file mode 100644 index 0000000..13182c9 --- /dev/null +++ b/login.py @@ -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")