Hi,
I call to Magento API rest using curl for have an authentification token, take datas and put them in a custom table.
Spoiler (Highlight to read) $userData = array ( "username" => $this -> getMagentoUsername (), "password" => "mypassword" );
$ch = curl_init ( "http://localhost/magento2/rest/V1/integration/admin/token" );
curl_setopt ( $ch , CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt ( $ch , CURLOPT_POSTFIELDS, json_encode ( $userData ));
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch , CURLOPT_HTTPHEADER, array ( "Content-Type: application/json" , "Content-Lenght: " . strlen ( json_encode ( $userData ))));
$token = curl_exec ( $ch );
$userData = array("username" => $this->getMagentoUsername(), "password" => "mypassword");$ch = curl_init("http://localhost/magento2/rest/V1/integration/admin/token");curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));$token = curl_exec($ch);
I would like to retrieved adminpassword but I can't because is hash.
The token is generated but I would like the password to be automatically written and not written by myself.
Like that, when an admin connects, it will be immediately authorized.
Thanks