Erreur de connexion

Hello,
Même problème ici.

Mathieu

[2022-07-10 04:36:04]DEBUG : [Technique][Consommation gaz] le 08/07/2022 : absence de données
[2022-07-10 04:36:22]INFO : [Technique][Consommation gaz] Authentication in progress..
[2022-07-10 04:36:22]DEBUG : [Technique][Consommation gaz] Authent1: {"timestamp":"2022-07-10T02:36:22.965+00:00","status":500,"error":"Internal Server Error","message":"","path":"/sofit-account-api/api/v1/auth"}
[2022-07-10 04:36:22]ERROR : [Technique][Consommation gaz] Authentification error
[2022-07-10 04:36:23]WARNING : [Technique][Consommation gaz] Error - Next try in one hour
[2022-07-10 05:36:04]DEBUG : [Technique][Consommation gaz] le 08/07/2022 : absence de données
[2022-07-10 05:36:48]INFO : [Technique][Consommation gaz] Authentication in progress..
[2022-07-10 05:36:48]DEBUG : [Technique][Consommation gaz] Authent1: {"timestamp":"2022-07-10T03:36:48.673+00:00","status":500,"error":"Internal Server Error","message":"","path":"/sofit-account-api/api/v1/auth"}
[2022-07-10 05:36:48]ERROR : [Technique][Consommation gaz] Authentification error
[2022-07-10 05:36:48]WARNING : [Technique][Consommation gaz] Error - Next try in one hour
[2022-07-10 06:36:04]DEBUG : [Technique][Consommation gaz] le 08/07/2022 : absence de données
[2022-07-10 06:36:43]INFO : [Technique][Consommation gaz] Authentication in progress..
[2022-07-10 06:36:43]DEBUG : [Technique][Consommation gaz] Authent1: {"timestamp":"2022-07-10T04:36:43.621+00:00","status":500,"error":"Internal Server Error","message":"","path":"/sofit-account-api/api/v1/auth"}
[2022-07-10 06:36:43]ERROR : [Technique][Consommation gaz] Authentification error
[2022-07-10 06:36:43]WARNING : [Technique][Consommation gaz] Error - Next try in one hour
[2022-07-10 07:36:04]DEBUG : [Technique][Consommation gaz] le 08/07/2022 : absence de données
[2022-07-10 07:36:44]INFO : [Technique][Consommation gaz] Authentication in progress..
[2022-07-10 07:36:44]DEBUG : [Technique][Consommation gaz] Authent1: {"timestamp":"2022-07-10T05:36:44.736+00:00","status":500,"error":"Internal Server Error","message":"","path":"/sofit-account-api/api/v1/auth"}
[2022-07-10 07:36:44]ERROR : [Technique][Consommation gaz] Authentification error
[2022-07-10 07:36:44]WARNING : [Technique][Consommation gaz] Error - Next try in one hour
[2022-07-10 08:36:04]DEBUG : [Technique][Consommation gaz] le 08/07/2022 : absence de données
[2022-07-10 08:36:41]INFO : [Technique][Consommation gaz] Authentication in progress..
[2022-07-10 08:36:42]DEBUG : [Technique][Consommation gaz] Authent1: {"timestamp":"2022-07-10T06:36:42.090+00:00","status":500,"error":"Internal Server Error","message":"","path":"/sofit-account-api/api/v1/auth"}
[2022-07-10 08:36:42]ERROR : [Technique][Consommation gaz] Authentification error
[2022-07-10 08:36:42]WARNING : [Technique][Consommation gaz] Error - Next try in one hour
[2022-07-10 09:36:04]DEBUG : [Technique][Consommation gaz] le 08/07/2022 : absence de données
[2022-07-10 09:36:24]INFO : [Technique][Consommation gaz] Authentication in progress..
[2022-07-10 09:36:24]DEBUG : [Technique][Consommation gaz] Authent1: {"timestamp":"2022-07-10T07:36:24.875+00:00","status":500,"error":"Internal Server Error","message":"","path":"/sofit-account-api/api/v1/auth"}
[2022-07-10 09:36:24]ERROR : [Technique][Consommation gaz] Authentification error
[2022-07-10 09:36:24]WARNING : [Technique][Consommation gaz] Error - Next try in one hour
1 « J'aime »

Bonjour,
la méthode de connexion a encore changée.
On a peut-être un indice de ce coté là

J’ai regardé un peu dans le code du plugin et ligne 327 il y quelque chose dans l’URL qui je pense nous bloque c’est nonce=7cV89oGyWnw28DYdI-702Gjy9f5XdIJ_4dKE_hbsvag
Je pense que cela vient de cela car j’ai l’impression qu’en comparant avec les autre codes que cela doit ce générer à chaque appel et qu’il devient obsolète au bout d’un moment.
Avez vous des infos?

1 « J'aime »

Vu ça :

Je pense que ca se joue avec la ligne 334 (le header commenté), mais aucune idée de comment l’ecrire par contre…

1 « J'aime »

Visiblement ça fait un moment que @hugoKs3 ne s’est pas connecté sur le forum.
J’ai réussi à me connecter via le plugin hier mais avec un code très différents.
Je vais voir pour vous transmettre une solution temporaire…

Pour ceux qui ne peuvent pas attendre…
remplacer la fonction connectJazpar par ceci:

public function connectJazpar($start, $end){
      $login = $this->getConfiguration('login');
      $password = $this->getConfiguration('password');
      $mypce = null;
      $conso = null;
      $comparison = null;
      $thresholds = null;

      log::add(__CLASS__, 'info', $this->getHumanName() . ' Authentication in progress..');

      
      $postdata = array(
        'password' => $password,
        'email' => $login,
        'capp' => 'meg',
        'goto' => 'https://sofa-connexion.grdf.fr:443/openam/oauth2/externeGrdf/authorize?response_type=code&scope=openid%20profile%20email%20infotravaux%20%2Fv1%2Faccreditation%20%2Fv1%2Faccreditations%20%2Fdigiconso%2Fv1%20%2Fdigiconso%2Fv1%2Fconsommations%20new_meg%20%2FDemande.read%20%2FDemande.write&client_id=prod_espaceclient&state=0&redirect_uri=https%3A%2F%2Fmonespace.grdf.fr%2F_codexch&nonce=7cV89oGyWnw28DYdI-702Gjy9f&by_pass_okta=1&capp=meg'
      );

      $curl = curl_init();
      $opts = array(
            CURLOPT_URL => 'https://login.monespace.grdf.fr/sofit-account-api/api/v1/auth',
            CURLOPT_RETURNTRANSFER => true,
            //CURLOPT_HEADER  => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_COOKIEFILE => '',
            CURLOPT_POSTFIELDS => http_build_query($postdata),
            CURLOPT_HTTPHEADER => [
              'Content-type: application/x-www-form-urlencoded; charset=UTF-8',
              'Referer: https://login.monespace.grdf.fr/mire/connexion?goto=https:%2F%2Fsofa-connexion.grdf.fr:443%2Fopenam%2Foauth2%2FexterneGrdf%2Fauthorize%3Fresponse_type%3Dcode%26scope%3Dopenid%2520profile%2520email%2520infotravaux%2520%252Fv1%252Faccreditation%2520%252Fv1%252Faccreditations%2520%252Fdigiconso%252Fv1%2520%252Fdigiconso%252Fv1%252Fconsommations%2520new_meg%2520%252FDemande.read%2520%252FDemande.write%26client_id%3Dprod_espaceclient%26state%3D0%26redirect_uri%3Dhttps%253A%252F%252Fmonespace.grdf.fr%252F_codexch%26nonce%3D7cV89oGyWnw28DYdI-702Gjy9f',
              'Domain: grdf.fr',
            ],
				
      );
      curl_setopt_array($curl, $opts);

      $response = curl_exec($curl);
      $responseStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

      log::add(__CLASS__, 'debug', $this->getHumanName() . ' Authent1: ' . $response);

      if ($responseStatus != "200") {
        log::add(__CLASS__, 'error', $this->getHumanName() . ' Authentification error');
        return null;
      } else {
        $obj = json_decode($response);
        if ($obj->state != "SUCCESS") {
          log::add(__CLASS__, 'error', $this->getHumanName() . ' Authentification error, state = ' . $obj->state . ', captcha = ' . $obj->displayCaptcha);
          if ($obj->displayCaptcha == true) {
            log::add(__CLASS__, 'error', $this->getHumanName() . ' Authentification error, a captcha needs to be entered on the website');
            if (config::byKey('captcha-warning','jazpar','',true) == 1) {
              message::add($this->getHumanName(), __('Un captcha a été détecté. Connectez-vous à votre espace pour le résoudre.',__FILE__), '', $this->getId());
            }
            if (config::byKey('captcha-disable','jazpar','',true) == 1) {
              $this->setIsEnable(0);
              log::add(__CLASS__, 'info', $this->getHumanName() . ' Equipment disabled (as per plugin config)');
            }
          }
          return null;
        }
      }

      curl_setopt($curl, CURLOPT_URL, "https://monespace.grdf.fr/");
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
      curl_setopt($curl, CURLOPT_HTTPHEADER, array('Referer: https://sofa-connexion.grdf.fr:443/openam/oauth2/externeGrdf/authorize?response_type=code&scope=openid profile email infotravaux /v1/accreditation /v1/accreditations /digiconso/v1 /digiconso/v1/consommations new_meg /Demande.read /Demande.write&client_id=prod_espaceclient&state=0&redirect_uri=https://monespace.grdf.fr/_codexch&nonce=7cV89oGyWnw28DYdI-702Gjy9f5XdIJ_4dKE_hbsvag&by_pass_okta=1&capp=meg'));

      $response = curl_exec($curl);
      $responseStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

      log::add(__CLASS__, 'debug', $this->getHumanName() . ' Authent2: ' . $response);

      if ($responseStatus != "200") {
        log::add(__CLASS__, 'error', $this->getHumanName() . ' Authentification error');
        return null;
      } else {
        log::add(__CLASS__, 'info', $this->getHumanName() . ' ...authenticated!');
      }

      if (empty($this->getConfiguration('pce'))) {
        log::add(__CLASS__, 'info', $this->getHumanName() . ' Retrieve PCE...');
        curl_setopt($curl, CURLOPT_URL, "https://monespace.grdf.fr/api/e-connexion/users/pce/historique-consultation");
        $response = curl_exec($curl);
        log::add(__CLASS__, 'debug', $this->getHumanName() . ' PCE: ' . $response);
        $responseStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        if ($responseStatus != "200") {
          log::add(__CLASS__, 'error', $this->getHumanName() . ' Unable to retrieve PCE');
          log::add(__CLASS__, 'debug', $this->getHumanName() . ' error: ' . $response);
          return null;
        } else {
          $obj = json_decode($response);
          foreach ($obj as $pce) {
            $mypce = $pce->numPce;
          }
          log::add(__CLASS__, 'info', $this->getHumanName() . ' ...PCE retrieved: '.$mypce);
        }
      } else {
        log::add(__CLASS__, 'info', $this->getHumanName() . ' PCE provided as input: ' . $this->getConfiguration('pce'));
        $mypce = $this->getConfiguration('pce');
      }

      log::add(__CLASS__, 'info', $this->getHumanName() . ' Get consumption data...');
      curl_setopt($curl, CURLOPT_URL, "https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?dateDebut=".$start."&dateFin=".$end."&pceList%5B%5D=". $mypce);
      $response = curl_exec($curl);
      log::add(__CLASS__, 'debug', $this->getHumanName() . ' conso: ' . $response);
      $responseStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

      if ($responseStatus != "200") {
        log::add(__CLASS__, 'error', $this->getHumanName() . ' Unable to retrieve consumption data');
        log::add(__CLASS__, 'debug', $this->getHumanName() . ' error: ' . $response);
        return null;
      } else {
        $conso = json_decode($response);
        log::add(__CLASS__, 'info', $this->getHumanName() . ' ...consumption data retrieved!');
      }

      log::add(__CLASS__, 'info', $this->getHumanName() . ' Get comparison data...');
      curl_setopt($curl, CURLOPT_URL, "https://monespace.grdf.fr/api/e-conso/pce/".$mypce."/consommation-anuelle-reference");
      $response = curl_exec($curl);
      log::add(__CLASS__, 'debug', $this->getHumanName() . ' comparison: ' . $response);
      $responseStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

      if ($responseStatus != "200") {
        log::add(__CLASS__, 'warning', $this->getHumanName() . ' Unable to retrieve comparison data');
        log::add(__CLASS__, 'debug', $this->getHumanName() . ' error: ' . $response);
      } else {
        $comparison = json_decode($response);
        log::add(__CLASS__, 'info', $this->getHumanName() . ' ...comparison data retrieved!');
      }

      $thresholdsType = config::byKey('thresholds-site','jazpar','',true);
      if ($thresholdsType == 1) {
        log::add(__CLASS__, 'info', $this->getHumanName() . ' Get monthly threshold datas...');
        curl_setopt($curl, CURLOPT_URL, "https://monespace.grdf.fr/api/e-conso/pce/".$mypce."/seuils?frequence=Mensuel");
        $response = curl_exec($curl);
        log::add(__CLASS__, 'debug', $this->getHumanName() . ' thresholds: ' . $response);
        $responseStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        if ($responseStatus != "200") {
          log::add(__CLASS__, 'warning', $this->getHumanName() . ' Unable to retrieve monthly thresholds data');
          log::add(__CLASS__, 'debug', $this->getHumanName() . ' error: ' . $response);
        } else {
          $thresholds = json_decode($response);
          log::add(__CLASS__, 'info', $this->getHumanName() . ' ...monthly thresholds data retrieved!');
        }
      }

      curl_close($curl);
      return array($mypce, $conso, $comparison, $thresholds);
   }

Attention je ne suis pas responsable d’éventuelles erreurs que vous commettrez … et cette modif n’engage que vous.

27 « J'aime »

Bonjour,
j’ai pu tester et ta solution fonctionne ^^.
Encore merci tu assure!
Jérôme

Bonjour,
Effectivement le fait d’ajouter le nom du domaine dans les optionp du curl semble régler le pb

2 « J'aime »

Salut limad44

Merci pour la correction, ca fonctionne chez moi également (je n’ai modifié que le header, je n’ai pas vu d’autres modifs en lisant en travers).

est ce que tu as proposé un PR sur le github du plugin? (https://github.com/hugoKs3/plugin-jazpar)

2 « J'aime »

Super Merci !

3 « J'aime »

Salut
Pas de PR pour l’instant, j, ai MP le dev par contre…

Hello @limad44 ,
Où doit-on apporter cette modification ? Dans quel fichier ?
Est-ce dans core/class/jazpar.class.php de la ligne 311 à 461 ?

Merci

4 « J'aime »

salut
oui c’est bien ça !

1 « J'aime »

Bonjour, ce fichier n’existe pas dans mon jeedom ?

2 « J'aime »

Erreur de ma part dans ma recherche.

2 « J'aime »

C’est OK avec la modification proposée.
Merci.

Super la correction, merci !

Super, cela refonctionne ! Merci !!

bonjour
vous auriez l’arborescence pour atteindre ce fichier core/class/jazpar.class.php sur rpi?
merci

1 « J'aime »

Bonjour, en utilisant l’éditeur de fichiers de Jeedom:
Onglets : Réglage → Système–> Editeur de fichiers.
a partir de l’éditeur : répertoire « Plugins » → et « jaspar ».

1 « J'aime »