Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

keystone Client returns 401

I am running a sample code which just list down the networks available.

please find below code 

from os import environ as env
import keystoneclient.v2_0.client as ksclient
from neutronclient.v2_0 import client as neutronclient
keystone = ksclient.Client(auth_url=env['OS_AUTH_URL'],
endpoint_url = keystone.service_catalog.url_for(service_type='network')
print endpoint_url
token = keystone.auth_token
neutron = neutronclient.Client(endpoint_url=endpoint_url, token=token)

But i am facing following error

Traceback (most recent call last):
  File "./", line 8, in <module>
  File "/usr/lib/python2.6/site-packages/keystoneclient/v2_0/", line 147, in __init__
  File "/usr/lib/python2.6/site-packages/keystoneclient/", line 318, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/keystoneclient/", line 425, in authenticate
    resp = self.get_raw_token_from_identity_service(**kwargs)
  File "/usr/lib/python2.6/site-packages/keystoneclient/v2_0/", line 181, in get_raw_token_from_identity_service
    return plugin.get_auth_ref(self.session)
  File "/usr/lib/python2.6/site-packages/keystoneclient/auth/identity/", line 79, in get_auth_ref
    authenticated=False, log=False)
  File "/usr/lib/python2.6/site-packages/keystoneclient/", line 430, in post
    return self.request(url, 'POST', **kwargs)
  File "/usr/lib/python2.6/site-packages/keystoneclient/", line 318, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/keystoneclient/", line 346, in request
    raise exceptions.from_response(resp, method, url)
keystoneclient.openstack.common.apiclient..exceptions.Unauthorized: Could not find project, ESS. (HTTP 401)

When i rune "neutron net-list" from the command line it works absolutely fine.

Has anything needs to be changed on the keystone to accept API calls ? am i missing anything. I checked the environment variables. They are set corrctly in both the cases .