Files
openstack-manuals/doc/user-guide/source/sdk_authenticate_against_networking_endpoint.rst
James Benson 9e798d4224 Corrected typo in neutronclient.v_2_0.client...
This bug fixes a small typo in the first line.
There is an additional '_' in the version. This has been removed.

Change-Id: Idf9061e13c2cbc26041a1a4b961cd85acb8007ff
Closes-Bug: 1564686
2016-04-01 16:34:57 +00:00

1.4 KiB

Authenticate against a Networking endpoint

To authenticate against a Networking endpoint, instantiate a neutronclient.v2_0.client.Client object:

from os import environ as env
from neutronclient.v2_0 import client as neutronclient
neutron = neutronclient.Client(auth_url=env['OS_AUTH_URL'],
                               username=env['OS_USERNAME'],
                               password=env['OS_PASSWORD'],
                               tenant_name=env['OS_TENANT_NAME'],
                               region_name=env['OS_REGION_NAME'])

You can also authenticate by explicitly specifying the endpoint and token:

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'],
                           username=env['OS_USERNAME'],
                           password=env['OS_PASSWORD'],
                           tenant_name=env['OS_TENANT_NAME'],
                           region_name=env['OS_REGION_NAME'])
endpoint_url = keystone.service_catalog.url_for(service_type='network')
token = keystone.auth_token
neutron = neutronclient.Client(endpoint_url=endpoint_url, token=token)