auth

emtellipro.auth

This module contains all the classes and methods necessary for authenticating with the API.

There’s no need to use any of these if using the Emtellipro class since that class uses this module internally.

Module Contents

Classes

NameDescription
AuthenticationDetailsConveniently stores the authentication details (access key, secret key) for use with all functions which require.
APIKeyContainer for the API key.

Functions

NameDescription
sign_requestAdds the necessary headers for authentication, in place, given the authdetails this class was instantiated with.
gen_auth_headerGenerates the cmplete HMAC Authorization header which contains the necessary signature for the request, and the details needed to verify it.
string_to_signGiven a Request object, this computes the string which the client needs to sign to verify the validity of the request.
compute_canonical_requestGiven a Request object, this computes the canonical request string which is then used for computing the signature of the request.

Data

_headers_to_sign

API

emtellipro.auth.AuthenticationDetails

class emtellipro.auth.AuthenticationDetails(accesskey, secretkey)

Bases: object

Conveniently stores the authentication details (access key, secret key) for use with all functions which require.

Initialization

Parameters:

  • accesskey: the API key used to identify the user
  • secretkey: the API key used to sign messages
AuthenticationDetails.accesskey
property accesskey

The access key stored in this object. Read-only.

AuthenticationDetails.secretkey
property secretkey

The secret key stored in this object. Read-only.

emtellipro.auth.APIKey

class emtellipro.auth.APIKey

Bases: object

Container for the API key.

New in version 6.10.

Initialization
__init__(apikey)
APIKey.apikey
apikey: str

The API key

emtellipro.auth.sign_request

emtellipro.auth.sign_request(
authdetails, request: httpx2.Request
) -> httpx2.Request

Adds the necessary headers for authentication, in place, given the authdetails this class was instantiated with.

Returns:

The same request that was passed in.

Return type: Request

emtellipro.auth.gen_auth_header

emtellipro.auth.gen_auth_header(
request, auth_details: emtellipro.auth.AuthenticationDetails
)

Generates the cmplete HMAC Authorization header which contains the necessary signature for the request, and the details needed to verify it.

Parameters:

request

The request to sign.

auth_details
emtellipro.auth.AuthenticationDetails

The holder for the authentication details.

Returns:

The ‘Authorization’ header value.

emtellipro.auth.string_to_sign

emtellipro.auth.string_to_sign(request)

Given a Request object, this computes the string which the client needs to sign to verify the validity of the request.

Parameters:

request

The request to sign.

Returns:

The string that will need to be signed (this will contain the hash of the request).

emtellipro.auth.compute_canonical_request

emtellipro.auth.compute_canonical_request(request)

Given a Request object, this computes the canonical request string which is then used for computing the signature of the request.

Parameters:

request

The request you want to sign.

Returns:

String representing the request in a consistent and deterministic format.