

def _get_auth(self, force=False, headers=None):
    if (headers is None):
        headers = {
            
        }
    if (force or (not AtomPubHandler.auth_token_cache)):
        auth_body = {
            'auth': {
                'RAX-KSKEY:apiKeyCredentials': {
                    'username': self.auth_user,
                    'apiKey': self.auth_key,
                },
            },
        }
        auth_headers = {
            'User-Agent': 'Winchester',
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        }
        logger.debug(('Contacting  auth server %s' % self.auth_server))
        res = requests.post(self.auth_server, data=json.dumps(auth_body), headers=auth_headers)
        res.raise_for_status()
        token = res.json()['access']['token']['id']
        logger.debug(('Token received: %s' % token))
        AtomPubHandler.auth_token_cache = token
    headers['X-Auth-Token'] = AtomPubHandler.auth_token_cache
    return headers

dataset/ETHPy150Open openstack/stacktach-winchester/winchester/pipeline_handler.py AtomPubHandler._get_auth/original