Forum

Python connection t...
 
Notifications
Retirer tout

Python connection to API

2 Posts
2 Utilisateurs
0 Reactions
2,406 Vu
(@xav38)
Posts: 1
New Member
Début du sujet
 
[#6729]

Hi ,

Thanks for creating ProjeQtOr, it is very relevant .

Our company would like to go further in order to automate or inject some data into ProjeQtOr. So we are trying to develop something in python by using the provided API.

We succeed to use GET api, for POST API it is more complicated. I would like to highlight we succeed to use the POST api with PHP, that means data send to the API are correctly formatted , the user key provided is the good one as well as the credentials .

The problem we encounter is related to encryption. I dig into the php code and I am wondering which encrypted data I have to produce.

In the documentation you provided for PHP , you are using "AesCtr::encrypt" for encrypting the module. Is it the behavior of this function I have to reproduce in python ? do you have more information ?

Thanks for your help.

The following PHP code work perfectly fine

$data=AesCtr::encrypt($data, $Key, 128);
$curl = curl_init($fullUrl);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, $Auth);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('data'=>$data));
$curl_response = curl_exec($curl);
echo $curl_response;
curl_close($curl);
?>


 
Posté : 28 Mai PM 16:055
(@babynus)
Posts: 14952
Membre Admin
 

In the documentation you provided for PHP , you are using "AesCtr::encrypt" for encrypting the module. Is it the behavior of this function I have to reproduce in python ? do you have more information ?

It is common AES encryption.
Similar library exist in python.
https://www.novixys.com/blog/using-aes-encryption-decryption-python-pycrypto/
https://pycryptodome.readthedocs.io/en/latest/src/cipher/aes.html

NB : by default we use AES128 as AES256 is illegal in some countries.


 
Posté : 1 Juin PM 13:066
Share:
Retour en haut