Méthode GET id/password

Bonsoir,

Je cale dans un projet où j'effectue une requête http (méthode GET). Cependant, l'adresse du serveur nécessite un id/password et je n'arrive pas à trouver la syntaxe. Dans le GET, j'ai essayé id:password (avant, après, entre) ou bien id:password@servername et bien d'autre tests.
Si l'un d'entre vous à une proposition de test pour implémenter le code ci-dessous, j'en serai heureux.

void sendWES(){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /RL.cgx?rl1=ON&rl2=OFFRL.cgx?rl1=ON&rl2=OFF");

    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }

bonjour,
où est la ligne id password?

tu es certain de cette ligne?

    client.print("GET /RL.cgx?rl1=ON&rl2=OFFRL.cgx?rl1=ON&rl2=OFF");

ca ne serait pas plutot

    client.print("GET /RL.cgx?rl1=ON&rl2=OFF");

que renvoie le serial print des connexions et les logs server?

Oh oui, il y a dans mon code un double copier-coller. Sorry :frowning:

l'id / password ne s'y trouve pas car je ne sais pas comment l''introduire.

Plus haut dans le code, il y a servername="192.168.1.8" mais cette adresse requiert un id/password

merci pour ton attention,

P

comment sont reconnus id et password sur le server?
apparemment, c'est sur ton server perso.

lorsque tu t'y connecte via ton pc, tu fais comment?

Et bien ceci dans mon navigateur fonctionne:

http://admin:toto@192.168.1.8/RL.cgx?rl1=ON&rl2=OFF

Si j'indique 192.168.1.8 alors une fenêtre avec les champs id et password

mets tout ton code
a tester, pas vérifié
serverName = admin;toto@192.168.1.8

Voici

#include <SPI.h>
#include <Ethernet2.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0x51, 0xB2 };   // Be sure this address is unique in your network

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3

// Debug mode
boolean DEBUG = true;
  //////////////
 //   End    //
//////////////


//char serverName[] = "login:toto@deneye.ddns.net:8000";
char serverName[] = "192.168.1.18";
boolean pinDevid1State = false;                // Save the last state of the Pin for DEVID1
boolean lastConnected = false;                 // State of the connection last time through the main loop

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):

EthernetClient client;

void setup() {

  Serial.begin(9600);
    
  pinMode(pinDevid1, INPUT);
  
  // start the Ethernet connection:
      
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);

}

void loop()
{
      ////
      // Listening for the pinDevid1 state
      ////
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON 
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;

 //       sendWES();
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;

        //Sending request to PushingBox when the pin is LOW
        sendWES();    
      }
      
      
      //DEBUG part
      // this write the respons from PushingBox Server.
      // You should see a "200 OK"
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
      
      // if there's no net connection, but there was one last time
      // through the loop, then stop the client:
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}


//Function for sending the request to PushingBox
void sendWES(){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
 //   client.println("GET /admin:toto");
    client.print("GET /RL.cgx?rl1=ON&rl2=OFF");

    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  } 
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}

edit ton post et vire le login et pass :slight_smile:

Oups !!!!

Personne ne connait une piste de solution ?

Pour rappel, lors de l'envoie d'une requête, comme il y a demande d'ID/password la métode GET me renvoit une erreur http 401. Il doit y avoir une ligne de code me permettant d'y indiquer l'ID/password.

Merci pour votre aide.