Created
May 30, 2020 00:33
-
-
Save PetraOleum/5ebe6f0cc238df56615d086fc061eb14 to your computer and use it in GitHub Desktop.
Mastodon.py secret generation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mastodon.py client setup | |
# Install mastodon module with pip install --user Mastodon.py or equiv | |
# See https://mastodonpy.readthedocs.io/en/stable/ for more information | |
from getpass import getpass | |
from mastodon import Mastodon | |
import argparse | |
parser = argparse.ArgumentParser(description = ("Generate secret file " | |
"for mastodon.py api")) | |
parser.add_argument("name", help="Name of app, e.g. mybot") | |
parser.add_argument("base_url", help=("Target domain, e.g. " | |
"\"https://mastodon.social\"")) | |
parser.add_argument("email", help=("Email account is registered to, e.g. " | |
"\"bot@example.com\"")) | |
args = parser.parse_args() | |
password = getpass() | |
Mastodon.create_app( | |
args.name, | |
api_base_url = args.base_url, | |
to_file = "{}_clientcred.secret".format(args.name) | |
) | |
mastodon = Mastodon( | |
client_id = "{}_clientcred.secret".format(args.name), | |
api_base_url = args.base_url | |
) | |
mastodon.log_in( | |
args.email, | |
password, | |
to_file = "{}_usercred.secret".format(args.name) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment