Authentication API

The auth module provides authentication mechanisms for the 1WorldSync API.

HMACAuth

class oneworldsync.auth.HMACAuth(app_id, secret_key)[source]

Bases: object

HMAC Authentication for 1WorldSync API

This class handles the HMAC authentication process required by the 1WorldSync API. It generates the necessary hash code based on the request parameters and secret key.

__init__(app_id, secret_key)[source]

Initialize the HMAC authentication with app_id and secret_key

Parameters:
  • app_id (str) – The application ID provided by 1WorldSync

  • secret_key (str) – The secret key provided by 1WorldSync

generate_timestamp()[source]

Generate a timestamp in the format required by the 1WorldSync API

Returns:

Timestamp in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ)

Return type:

str

generate_hash(string_to_hash)[source]

Generate a hash code for the given string using HMAC-SHA256

Parameters:

string_to_hash (str) – The string to hash

Returns:

Base64-encoded hash code

Return type:

str

prepare_auth_params(path, query_params)[source]

Prepare authentication parameters for a request

Parameters:
  • path (str) – API endpoint path

  • query_params (dict) – Query parameters for the request

Returns:

Updated query parameters with authentication information

Return type:

dict

get_auth_url(protocol, domain, path, query_params)[source]

Get a fully authenticated URL for the 1WorldSync API

Parameters:
  • protocol (str) – URL protocol (http:// or https://)

  • domain (str) – API domain

  • path (str) – API endpoint path

  • query_params (dict) – Query parameters for the request

Returns:

Fully authenticated URL

Return type:

str