Exemplo n.º 1
0
def login_fn(username, password):
    """ Logs in to Snark AI"""
    token = ""
    if token:
        logger.info("Token login.")
        logger.degug("Getting the token...")
        token = click.prompt(
            "Please paste the authentication token from {}".format(
                config.GET_TOKEN_REST_SUFFIX, type=str, hide_input=True))
        token = token.strip()
        AuthClient.check_token(token)
    else:
        logger.info(
            "Please log in using Activeloop credentials. You can register at https://app.activeloop.ai "
        )
        if not username:
            logger.debug("Prompting for username.")
            username = click.prompt("Username", type=str)
        username = username.strip()
        if not password:
            logger.debug("Prompting for password.")
            password = click.prompt("Password", type=str, hide_input=True)
        password = password.strip()
        token = AuthClient().get_access_token(username, password)
    TokenManager.set_token(token)
    HubControlClient().get_credentials()
    logger.info("Login Successful.")
Exemplo n.º 2
0
def register(username, email, password):
    """ Register at Activeloop AI"""
    if not username:
        logger.debug("Prompting for username.")
        username = click.prompt("Username", type=str)
    username = username.strip()
    if not email:
        logger.debug("Prompting for email.")
        email = click.prompt("Email", type=str)
    email = email.strip()
    if not password:
        logger.debug("Prompting for password.")
        password = click.prompt("Password", type=str, hide_input=True)
    password = password.strip()
    AuthClient().register(username, email, password)
    token = AuthClient().get_access_token(username, password)
    TokenManager.set_token(token)
    consent_message = textwrap.dedent("""
        Privacy policy:
        We collect basic system information and crash reports so that we can keep
        improving your experience using Hub to work with your data.

        You can find out more by reading our privacy policy:
            https://www.activeloop.ai/privacy/

        If you would like to opt out of reporting crashes and system information,
        run the following command:
            $ hub reporting --off
        """)
    logger.info(consent_message)
    configure_reporting(True, username=username)
Exemplo n.º 3
0
    def get_credentials(self):

        if self.auth_header is None:
            token = AuthClient().get_access_token(username="******",
                                                  password="")
            self.auth_header = f"Bearer {token}"

        r = self.request(
            "GET",
            config.GET_CREDENTIALS_SUFFIX,
            endpoint=config.HUB_REST_ENDPOINT,
        ).json()

        details = {
            "_id": r["_id"],
            "region": r["region"],
            "session_token": r["session_token"],
            "access_key": r["access_key"],
            "secret_key": r["secret_key"],
            "endpoint": r["endpoint"],
            "expiration": r["expiration"],
            "bucket": r["bucket"],
        }

        self.save_config(details)
        return details
Exemplo n.º 4
0
def register(username, email, password):
    """ Register at Activeloop AI"""
    if not username:
        logger.debug("Prompting for username.")
        username = click.prompt("Username", type=str)
    username = username.strip()
    if not email:
        logger.debug("Prompting for email.")
        email = click.prompt("Email", type=str)
    email = email.strip()
    if not password:
        logger.debug("Prompting for password.")
        password = click.prompt("Password", type=str, hide_input=True)
    password = password.strip()
    AuthClient().register(username, email, password)
    token = AuthClient().get_access_token(username, password)
    TokenManager.set_token(token)