glanceclient.exc.HTTPUnauthorized: 401 Unauthorized

asked 2017-02-14 07:59:33 -0600

Ravindhar gravatar image

Hi All, I am able to get the list of images using CLI and horizon but when I directly connect to glance client then I am getting above exception (This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.) But my credentials are correct here is my code

import glanceclient.v2.client as glclient glance = glclient.Client(version='2',endpoint='http://XX.XX.XX.XX:9292', username='admin', password='XXXX', project_id='admin', auth_url='http://XX.XX.XX.XX:5000/v2.0',project_name='admin',tenant_id='admin',tenant_name='admin',user_domain_name='Default',project_domain_name='Default',region_name='dev_newton') images = glance.images.list()

edit retag flag offensive close merge delete


tenant_id='admin' doesn't look correct.Try leaving it out, or replace 'admin' with the tenant ID. Also, there are no projects or domains in Keystone version 2, but I don't know if that is a problem.

Bernd Bausch gravatar imageBernd Bausch ( 2017-02-14 19:30:34 -0600 )edit

@Berns Bausch : I tried with your suggestion but getting same issue

glance = glclient.Client(version='2',endpoint='', username='admin', api_key='root123', auth_url='',project_name='admin',region_name='dev_newton')
Ravindhar gravatar imageRavindhar ( 2017-02-14 23:36:07 -0600 )edit

When your the CLI commands are successful, what options and what shell environment do you use?

Bernd Bausch gravatar imageBernd Bausch ( 2017-02-14 23:42:20 -0600 )edit

export OS_PROJECT_DOMAIN_NAME=Default export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=root123 export OS_AUTH_URL=http://XX.XX.XX.XX:35357/v3 export OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2

Ravindhar gravatar imageRavindhar ( 2017-02-14 23:52:25 -0600 )edit

So, are you certain that v2 is enabled in your cloud? Check this with curl Also, try using the same parameters as your environment, in particular auth_url=http://xxxxx:35357/v3.

Bernd Bausch gravatar imageBernd Bausch ( 2017-02-15 06:34:21 -0600 )edit