from mastodon import Mastodon import config def register_app(): Mastodon.create_app( config.APP_NAME, website=config.APP_WEBSITE, api_base_url=config.APP_INSTANCE_URL, to_file='secrets.txt') app = Mastodon(client_id='secrets.txt') print("Browse to the OAuth authorization page at") print(app.auth_request_url()) app.log_in( code=input("and paste here the OAuth authorization code: "), to_file='secrets.txt') print("Registration complete") if __name__=='__main__': print(""" This utility should only be run *once* (if you see the file "secrets.txt", you probably shouldn't run this). You should also make sure that you've edited "config.py" with the relevant APP_INSTANCE_URL etc., and that you don't violate the instance's code of conduct by running your bot (ask an admin if unsure).""") input("Hit enter if you're ready to register your app with your mastodon server, otherwise — hit Ctrl-C ") register_app()