openstack-manuals/doc/user-guide/section_sdk_auth_keystone.xml
Andreas Jaeger a317a8fff5 Openstack -> OpenStack
Fix wrong capitalizations of OpenStack.

Change-Id: Iab823200c0f4c4310f3693ea8bd4a6d9b5aa0cdc
2014-02-15 10:03:24 +01:00

39 lines
2.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
xml:id="sdk_auth_keystone">
<title>Authenticate against an Identity Service endpoint</title>
<para>To authenticate against the Identity Service v2.0 endpoint,
instantiate a <link
xlink:href="http://docs.openstack.org/developer/python-keystoneclient/api/keystoneclient.v2_0.client.html#keystoneclient.v2_0.client.Client"
> keystoneclient.v_20.client.Client</link> object:</para>
<programlisting language="python">from os import environ as env
import keystoneclient.v2_0.client as ksclient
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'])</programlisting>
<para>After you instantiate a <classname>Client</classname> object,
you can retrieve the token by accessing its
<literal>auth_token</literal> attribute object:</para>
<programlisting language="python">import keystoneclient.v2_0.client as ksclient
keystone = ksclient.Client(...)
print keystone.auth_token</programlisting>
<para>If the OpenStack cloud is configured to use public-key
infrastructure (PKI) tokens, the Python script output looks
something like this:</para>
<screen><computeroutput>MIIQUQYJKoZIhvcNAQcCoIIQQjCCED4CAQExCTAHBgUrDgMCGjCCDqcGCSqGSIb3DQEHAaCCDpgE
gg6UeyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxMy0xMC0yMFQxNjo1NjoyNi
4zNTg2MjUiLCAiZXhwaXJlcyI6ICIyMDEzLTEwLTIxVDE2OjU2OjI2WiIsICJpZCI6ICJwbGFjZWhv
...
R3g14FJ0BxtTPbo6WarZ+sA3PZwdgIDyGNI-0Oqv-8ih4gJC9C6wBCel1dUXJ0Mn7BN-SfuxkooVk6
e090bcKjTWet3CC8IEj7a6LyLRVTdvmKGA5-pgp2mS5fb3G2mIad4Zeeb-zQn9V3Xf9WUGxuiVu1Hn
fhuUpJT-s9mU7+WEC3-8qkcBjEpqVCvMpmM4INI=</computeroutput></screen>
<note>
<para>This example shows a subset of a PKI token. A complete token
is over 5000 characters long.</para>
</note>
</section>