python-cratonclient/doc/source/usage/authentication.rst
Ian Cordasco 75c3531c43 Add user documentation for the Python API
Most of the copy is duplicated except for the places where it matters.
This allows for any page of this documentation to be page one. If
someone only cares about using hosts first, they can go directly there
and start listing hosts, creating them, etc. without much other
prompting.

Change-Id: Id621947af5d4c3ca53af24904f5f16d3d88bc8b8
2017-03-17 12:57:17 -05:00

1.5 KiB

Authenticating to Craton

There are two ways to authenticate to Craton:

  1. Using Craton's in-built authentication system (the default)
  2. Using Keystone

Craton Authentication

In the Craton Authentication case, you need the URL for the Craton API service, your username, project ID, and token. To set up cratonclient for this authentication, you need only do the following:

from cratonclient import auth
from cratonclient.v1 import client

craton_session = auth.craton_auth(
    username=USERNAME,
    token=TOKEN,
    project_id=PROJECT_ID,
)

craton = client.Client(
    session=craton_session,
    url=URL,
)

Keystone Authentication

When authenticating to Craton using Keystone, you need to know:

  • the URL to use to authenticate to Keystone which we will refer to as AUTH_URL
  • the username
  • the password
  • the project ID or name
  • the user domain ID or name
  • and the project domain ID or name

Then, we need to do the following:

from cratonclient import auth
from cratonclient.v1 import client

craton_session = auth.keystone_auth(
    auth_url=AUTH_URL,
    password=PASSWORD,
    username=USERNAME,
    user_domain_name=USER_DOMAIN_NAME,
    project_name=PROJECT_NAME,
    project_domain_name=PROJECT_DOMAIN_NAME,
)
craton = client.Client(
    session=craton_session,
    url=URL,
)