Python:
signature = base64.b64encode(hmac.new(secret_key, policy, sha256).digest())
PHP:
$signature = base64_encode(hash_hmac('sha256', $policy, $secretkey, true));
# Python: hmac.new(secret_key, policy, sha256).hexdigest()
# PHP: hash_hmac('sha256', $policy, $secretkey, false)