예제 #1
0
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
예제 #2
0
파일: auth.py 프로젝트: SteelPangolin/toot
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
예제 #3
0
파일: commands.py 프로젝트: sudoWright/toot
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