Requests-Cloud-Auth - Simple cloud auth extensions

If you're like me, you've run into the situation where you want to interface with your cloud resources, but you don't want to use the official clients due to the number of dependencies it would introduce into your project. This is where the requests-cloud-auth library comes in. You can make the one or two cloud API calls you need without incurring the expense of heavy cloud clients.

Requests-Cloud-Auth is a simple collection of extensions for the Requests library that will do the work of authenticating, caching tokens, and adding header information to your HTTP requests. Currently, the library only supports Keystone V2 and Rackspace Cloud; however, in the future I plan on including support for Keystone V3, HP Cloud, Digital Ocean, and other cloud providers as people request them.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)

Installation:

1
pip install requests-cloud-auth

Project Links: