Skip to content

Session

Hugh Jeremy edited this page Oct 4, 2018 · 2 revisions

Documentation > Session

Sessions are the keys to the Amatino kingdom. All requests to the Amatino API, except those requests to create Sessions themselves, must include two HTTP headers: An integer session identifier, and a Hashed Message Authentication Code (HMAC) signed with a Session API Key. The Amatino Python Session class handles all authentication requirements for you, inclusion HMAC computation.

Creating a Session with a POST request is analogous to 'logging in', and deleting a Session with a DELETE request is analogous to 'logging out'. Your application might wish to create multiple Sessions for a User. For example, one per device.

Properties

.api_key - str

The base64-encoded key that authenticates the User of this Session. You should not interact with this value unless you understand the security implications.

Under the hood, this is a 256-bit random number generated in a cryptographically secure manner.

Example: '4LGpi3-kMcyRHY-MW3Qa2HzJ2tIvNJfuOkffq5-uVzE='

.session_id - int

A 64-bit integer identifier for this Session.

Example: 4316974952633910666


.user_id - int

The 64-bit integer identifier of the User authenticated by this Session.

Example: 8973009721414582153


.id_ - int

Returns .session_id. Provided as convenience for consistency with the many other Amatino Python classes that use id_ as the name for their unique identifier.

Methods

classmethod .create_with_email() -> Session

Return a new Session created using a User email as the identifying credential

Parameters

  1. email - str
  2. secret - str

Example

session = Session.create_with_email(
  email='clever@example.com',
  secret='high entropy passphrase'
)

classmethod .create_with_user_id() -> Session

Return a new Session created using a User integer identifier as the identifying credential.

Parameters

  1. user_id - int
  2. secret - str

Example

session = Session.create_with_user_id(
  user_id=8973009721414582153,
  secret='High entropy passphrase'
)