Welcome to Requests-Cloud-Auth’s documentation!¶
Requests-Cloud-Auth is a collection of Authentication extensions for the Requests library. The primary purpose of this collection is to provide an easy interface to authenticate to cloud providers with minimal dependencies.
Supported¶
- Keystone v2
- Rackspace Identity
- Keystone v3
- HP Cloud - Future
- Digital Ocean - Future
- AWS - Future
Documentation¶
Keystone V2 Authentication Extension¶
This authentication extension enables simple authentication to Keystone V2 endpoints.
Sample Usage¶
import requests
from requests_cloud_auth import keystone
keystone_auth = keystone.KeystoneV2PasswordAuth(
endpoint='https://a.keystone.server',
username='demo',
password='cool',
tenant_name='my_tenant'
)
resp = requests.get('http://openstack_service/', auth=keystone_auth)
Extension API Documentation¶
-
class
requests_cloud_auth.keystone.
KeystoneV2PasswordAuth
(endpoint, username, password, tenant_name)¶ Authentication extension for Requests that supports Keystone V2
Parameters: - endpoint (str) – Keystone endpoint URI to authenticate to
- username (str) – Valid Keystone username
- password (str) – Valid Keystone password
- tenant_name (str) – Valid Keystone tenant name
Returns: Instance of KeystoneV2PasswordAuth
-
authenticate
()¶ Gets authentication credentials
Attempts to use cached credentials before making a remote call. Automatically called by requests when needed, but can be manually called when needed.
Keystone V3 Authentication Extension¶
This authentication extension enables simple authentication to Keystone V3 endpoints.
Sample Usage¶
import requests
from requests_cloud_auth import keystone
keystone_auth = keystone.KeystoneV3PasswordAuth(
endpoint='https://a.keystone.server',
username='demo',
password='cool',
project_name='my_project'
)
resp = requests.get('http://openstack_service/', auth=keystone_auth)
Extension API Documentation¶
-
class
requests_cloud_auth.keystone.
KeystoneV3PasswordAuth
(endpoint, username, password, project_name)¶ Authentication extension for Requests that supports Keystone V3
Parameters: - endpoint (str) – Keystone endpoint URI to authenticate to
- username (str) – Valid Keystone username
- password (str) – Valid Keystone password
- project_name (str) – Valid Keystone project name
Returns: Instance of KeystoneV3PasswordAuth
-
authenticate
()¶ Gets authentication credentials
Attempts to use cached credentials before making a remote call. Automatically called by requests when needed, but can be manually called when needed.
Rackspace Identity Authentication Extension¶
This authentication extension enables simple authentication to Rackspace Cloud endpoints.
Sample Usage¶
import requests
from requests_cloud_auth import rackspace
auth = rackspace.RackspacePasswordAuth(
username='my_user',
password='my_pass'
)
# Pre-auth as we need our project_id to list our cloud servers
auth.authenticate()
url = 'https://ord.servers.api.rackspacecloud.com/v2/{0}/servers'.format(auth.project_id)
resp = requests.get(url, auth=auth)
Extension API Documentation¶
-
class
requests_cloud_auth.rackspace.
RackspacePasswordAuth
(username, password, endpoint=None, region='US')¶ - Authentication extension for Requests that supports Rackspace
- password authentication.
Parameters: - username – Valid Rackspace Cloud username
- password – Valid Rackspace Cloud password
- endpoint – (optional) URI to override authentication endpoint
- region – (optional) Specify the Rackspace Cloud region. Supported values: US, UK
Returns: Instance of RackspacePasswordAuth
-
authenticate
()¶ Gets authentication credentials
Attempts to use cached credentials before making a remote call. Automatically called by requests when needed, but can be manually called when needed.
-
class
requests_cloud_auth.rackspace.
RackspaceApiKeyAuth
(username, api_key, endpoint=None, region='US')¶ - Authentication extension for Requests that supports Rackspace
- API key authentication.
Parameters: - username – Valid Rackspace Cloud username
- api_key – Valid Rackspace Cloud API key
- endpoint – (optional) URI to override authentication endpoint
- region – (optional) Specify the Rackspace Cloud region. Supported values: US, UK
Returns: Instance of RackspaceApiKeyAuth
-
authenticate
()¶ Gets authentication credentials
Attempts to use cached credentials before making a remote call. Automatically called by requests when needed, but can be manually called when needed.
Project Links¶
GitHub: jmvrbanac/requests-cloud-auth