cremalink.clients.auth module

class cremalink.clients.auth.CloudToken(refresh_token: str)[source]

Bases: object

Responsible for handling authentication with the Ayla IoT cloud platform. This module implements the multi-step authentication flow required to obtain a refresh token, which can be used for API interactions.

save(path: str = 'token.json') str[source]
cremalink.clients.auth.authenticate_cloud(email: str, password: str, language: str = 'en') CloudToken[source]

Performs the multi-step authentication flow to obtain a refresh token for the Ayla IoT cloud platform.

This function executes the following steps: 1. Authorize: Initiates the authorization process to obtain a context parameter. 2. Get IDs: Retrieves necessary IDs (ucid, gmid, gmid_ticket) for the login process. 3. Login: Authenticates the user with their email and password, along with risk context information, to obtain a login token. 4. Get User Info: Fetches user information using the login token to obtain UID, UIDSignature, and signatureTimestamp. 5. Consent: Simulates the user consent process to obtain a signature for the authorization continue step. 6. Authorization Continue: Continues the authorization process using the context, login token, and consent signature to obtain an authorization code. 7. IDP Token: Exchanges the authorization code for an IDP token. 8. Exchange for Ayla: Uses the IDP token to sign in to the Ayla cloud and obtain a refresh token.

Parameters:
  • email (str) – The user’s email address for authentication.

  • password (str) – The user’s password for authentication.

  • language (str) – The preferred language for the authentication process (default is “en”).

Returns:

An instance of CloudToken containing the obtained refresh token.

Return type:

CloudToken