'def get_api_key( self, trans, **kwd )
* GET /api/authenticate/baseauth
returns an API key for authenticated user based on BaseAuth headers
:returns: api_key in json format
:rtype:   dict
:raises: ObjectNotFound, HTTPBadRequest'

@expose_api_anonymous_and_sessionless
def get_api_key(self, trans, **kwd):

    (email, password) = self._decode_baseauth(trans.environ.get('HTTP_AUTHORIZATION'))
    user = trans.sa_session.query(trans.app.model.User).filter((trans.app.model.User.table.c.email == email)).all()
    if (len(user) == 0):
        raise exceptions.ObjectNotFound('The    user    does    not    exist.')
    elif (len(user) > 1):
        raise exceptions.InconsistentDatabase('An    error    occured,    please    contact    your    administrator.')
    else:
        user = user[0]
        is_valid_user = self.app.auth_manager.check_password(user, password)
    if is_valid_user:
        key = self.api_keys_manager.get_or_create_api_key(user)
        return dict(api_key=key)
    else:
        raise exceptions.AuthenticationFailed('Invalid    password.')
