ra1u / redis-dart

fast redis protocol parser and client
MIT License
84 stars 35 forks source link

How to authenticate in the connection? #57

Closed Gabsop closed 2 years ago

Gabsop commented 2 years ago

image I'm trying to connect to the Redis but I have no idea how do I put my username and password to enter with TLS.

ra1u commented 2 years ago

First command you send should be auth.

conn.connectSecure(<args>).than((Command command){
     command.send_object(["AUTH","username","password"])
     .then((var response) {
       print(response);
       command.send_object(["SET","token","value]).then(
          (var response) => print(response));
     });
});

Or equivalently using async

Command command = await conn.connectSecure(<args>);
var rsp_auth = await command.send_object(["AUTH","username","password"]);
print(rsp_auth);
var rsp_token = await command.send_object((["SET","token","value]));
print(rsp_token);

I did not compile this, so let me know how this works for you.