def login()

in dynalab_cli/utils.py [0:0]


def login():
    api_token = APIToken()
    if api_token.exists():
        ops = input(
            "An account is already logged in. \
            Do you want to logout and re-login another account? (Y/N)\n"
        )
        if ops.lower().strip() == "y":
            logout()
        else:
            print("Current account remains logged in.")
    else:
        print(
            "A browser window will open prompting you to login, "
            + "after login please copy the API token and paste it here"
        )
        print(f"Opening in browser: {DYNABENCH_WEB}/generate_api_token")
        webbrowser.open_new_tab(f"{DYNABENCH_WEB}/generate_api_token")
        user_token = input("Paste your API token here: ")
        api_token.save(user_token)
        print("Successfully logged in.")