def authenticate(cmd_args, endpoint='', force=False):
    """Returns an OAuth token that can be passed to the server for
    identification. If FORCE is False, it will attempt to use a cached token
    or refresh the OAuth token.
    """
    server = server_url(cmd_args)
    network.check_ssl()
    access_token = None

    try:
        assert not force
        access_token = refresh_local_token(server)
    except Exception:
        print('Performing authentication')
        access_token = perform_oauth(get_code, cmd_args, endpoint)
        email = display_student_email(cmd_args, access_token)
        if not email:
            log.warning('Could not get login email. Try logging in again.')

    log.debug('Authenticated with access token={}'.format(access_token))

    return access_token
def authenticate ( cmd_args , endpoint = '' , force = False ) : server = server_url ( cmd_args ) network . check_ssl ( ) access_token = None try : assert not force access_token = refresh_local_token ( server ) except Exception : print ( 'Performing authentication' ) access_token = perform_oauth ( get_code , cmd_args , endpoint ) email = display_student_email ( cmd_args , access_token ) if not email : log . warning ( 'Could not get login email. Try logging in again.' ) log . debug ( 'Authenticated with access token={}' . format ( access_token ) ) return access_token
Returns an OAuth token that can be passed to the server for
    identification. If FORCE is False, it will attempt to use a cached token
    or refresh the OAuth token.