Auth

This file implements features related to Authentication for the CloudCIX API.

auth.get_token(password, api_key)

Attempts to generate a CloudCIX token for any given email, password, and api_key combination. This method will return the token if it was successfully created. If any errors are returned from the API, a CloudCIXAuthException will be raised by this method.

If there is an error connecting to the API, or the API has an internal error, a normal Exception will be raised. This Exception will contain the content of the response as its message.

Parameters:
  • email (str) – The email address to use for authentication.

  • password (str) – The password to use for authentication.

  • api_key (str) – The api_key of the Member the user is logging in under.

auth.get_admin_token()

Generates an admin token using the credentials specified in the settings module (CLOUDCIX_API_USERNAME, CLOUDCIX_API_PASSWORD, and CLOUDCIX_API_KEY).

class cloudcix.auth.TokenAuth(token)

Wrapper around requests.auth.AuthBase that is designed to put a token into the correct header for use with our API.

__call__(request)

Used to set the correct header in the request when the request is about to be sent.

Parameters:

request (requests.Request) – The request that this TokenAuth instance has been used for.

__eq__(other)

Compares two instances of the TokenAuth class to check if they have the same token.

Parameters:

other (cloudcix.auth.TokenAuth) – Another instance of TokenAuth that will be compared against this one.

__init__(token)

Create an instance of the TokenAuth class with a specified token

Parameters:

token (str) – The token that will be used to authenticate the request.