コード例 #1
0
ファイル: auth.py プロジェクト: naegelyd/solvebio-python
def logout(args):
    if get_credentials():
        delete_credentials()
        client.auth = None
        print 'You have been logged out.'
    else:
        print 'You are not logged-in.'
コード例 #2
0
ファイル: auth.py プロジェクト: naegelyd/solvebio-python
def login(args):
    """
    Prompt user for login information (email/password).
    Email and password are used to get the user's auth_token key.
    """
    delete_credentials()

    email, password = _ask_for_credentials()
    data = {
        'email': email,
        'password': password
    }
    try:
        response = client.request('post', '/v1/auth/token', data)
    except SolveError as e:
        print 'Login failed: %s' % e.message
    else:
        save_credentials(email.lower(), response['token'])
        # reset the default client's auth token
        solvebio.api_key = response['token']
        _send_install_report()
        print 'You are now logged-in.'