Ethernet client connect with password?

I've been developing a project that uses ATMega 2560 + Ethernet Shield. The project is set up as a client and works fine on my home/office network. However, I now need to move the project onto a secure corporate network. After speaking with their IT representative, I need to hardcode the IP address, server, gateway, and subnet mask. That's not a problem.

What seems to be a problem is that I also need to hard code a password. If I were using WiFi shield this would not be a problem, but I cannot find an example of passing a password for client .connect(args).

Can you point me to any successful examples or resources that allow me to pass a password, or can you help me understand how I would need to modify the library to add a new function that would accomplish this?

I've not posted my code, because it's basically the web client example with IP address, server, gateway, and subnet mask

Search the forum for basicauth or base64.

This is the same as HTTP Basic Authentication?

PaladinEng: This is the same as HTTP Basic Authentication?

Yes.

After testing on-site today, I was not able to connect successfully…sort of.
client.connect(server,80) seems to have failed. I get the “connection failed” message from the serial monitor.
But I can ping the device,even after the “connection failed” message.
I also tried sending the base64 encoded string as shown in the code (ignore that it is commented out)

The IT support I was working with was not sure what the problem is on their side, And I’m hoping that you can look at my code and make suggestions from this side.

So, here’s my code.

#include <Ethernet.h>
#include <SPI.h>

// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x19, 0x2F };
//the IP address for the shield:
byte ip[] = { XX, XX, XX, XX };                 // this is the assigned ip within the LAN
// the router's gateway address:
byte gateway[] = { XX, XX, XX, XX };     // neccessary to get access to the internet via your router
// the subnet:
byte subnet[] = { XX, XX, XX, XX };
//the proxy server
byte server[] = {XX, XX, XX, XX};                 

EthernetClient client;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  
  // start the Ethernet connection:
  Ethernet.begin(mac, ip, gateway, subnet);
   // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server,80)) {
    //client.write("QzF5WXIxXG15cW14FkJheWVyMTIz");  //Base 64 encode user_name:password""
    Serial.println("connected");
     // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: Close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available 
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}

Thanks

If that is the correct base64 encoding of your user:password, then:

 if (client.connect(server,80)) {
    Serial.println("connected");
     // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Authorization: Basic QzF5WXIxXG15cW14FkJheWVyMTIz"); 
    client.println("Host: www.google.com");
    client.println("Connection: Close");
    client.println();

I altered the base 64 encoding before posting, but it is correct. I changed the order of the client.println() statements to match yours, but no joy.

However, we switch from passing the proxy server as an IP address to passing the the name of the server, and it seems that this part is working.

if (client.connect(proxyServer,8080)) {
     Serial.println("connected");

Wondering now if the proxy is blocking return traffic from the PUT/ GET statements I've been working with.

Is there a sketch that will let me tell the shield to ping, or to get a trace? I'm googling for it, but coming up empty, probably because I'm looking for the wrong things.