def create_app_interactive(): instance = input("Choose an instance [%s]: " % green(DEFAULT_INSTANCE)) if not instance: instance = DEFAULT_INSTANCE base_url = 'https://{}'.format(instance) print("Registering application with %s" % green(base_url)) try: app = api.create_app(base_url) except: raise ConsoleError("Failed authenticating application. Did you enter a valid instance?") save_app(app) print("Application tokens saved to: {}".format(green(CONFIG_APP_FILE))) return app
def register_app(domain, scheme='https'): print_out("Looking up instance info...") instance = api.get_instance(domain) print_out( "Found instance <blue>{}</blue> running Mastodon version <yellow>{}</yellow>" .format(instance['title'], instance['version'])) try: print_out("Registering application...") response = api.create_app(domain, scheme) except ApiError: raise ConsoleError("Registration failed.") base_url = scheme + '://' + domain app = App(domain, base_url, response['client_id'], response['client_secret']) config.save_app(app) print_out("Application tokens saved.") return app
def register_app(instance): print("Registering application with %s" % green(instance)) try: response = api.create_app(instance) except: raise ConsoleError( "Registration failed. Did you enter a valid instance?") base_url = 'https://' + instance app = App(instance, base_url, response['client_id'], response['client_secret']) path = config.save_app(app) print("Application tokens saved to: {}\n".format(green(path))) return app