Ask Your Question

keystone Client returns 401

asked 2014-11-05 08:32:34 -0500

Gaurav Suryagandh gravatar image
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 .

edit retag flag offensive close merge delete


check whether the neutron service is up, also check you are running script where neutron is running

Syed Awais Ali gravatar imageSyed Awais Ali ( 2014-11-05 10:10:43 -0500 )edit

2 answers

Sort by » oldest newest most voted

answered 2014-11-05 08:59:55 -0500

Adrián Norte gravatar image

It seems that the script isn't passing the tenant name correctly. Could you try to print the query to stdout instead to sending it and see if everything is correct?

edit flag offensive delete link more


Here is a quick update i modified my code to use v3 and now my keystone client is getting created. But now i am stuck at keystone.service_catalog.url_for(service_type='network')

Gaurav Suryagandh gravatar imageGaurav Suryagandh ( 2014-11-05 10:23:40 -0500 )edit

is there a new error or something with the new code or just the same error?

Adrián Norte gravatar imageAdrián Norte ( 2014-11-05 10:50:22 -0500 )edit

can you try this to see what happens?

endpoint_url = keystone.service_catalog.url_for(service_type='network', endpoint_type='publicURL')

Adrián Norte gravatar imageAdrián Norte ( 2014-11-05 10:55:17 -0500 )edit

answered 2014-11-05 10:23:58 -0500

Gaurav Suryagandh gravatar image

updated 2014-11-05 11:13:28 -0500

here is my new code

from os import environ as env
from keystoneclient import client
from neutronclient.v2_0 import client as neutronclient

keystone = client.Client(auth_url=env['OS_AUTH_URL'],
print keystone
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-11-05 08:32:34 -0500

Seen: 1,312 times

Last updated: Nov 05 '14