Db login action script (postgresql) Unknown authenticationOk message

Hi.
I am trying a custom database login action script (against my postgresql db) using the template and getting the error:

the db is postgres 13.x

“Unknown authenticationOk message typeMessage { name: ‘authenticationOk’, length: 23 }”

  1. I verified the target postgres url + credential I am using to login work fine (from a separate client)

  2. using the "test’ feature on the login script page I get the error: “Unknown authenticationOk message typeMessage { name: ‘authenticationOk’, length: 23 }”

Hi @bitsofinfo,

This issue appears to be coming from pg. Can please share a code snippet of how you are authenticating (remove sensitive data)? Also have you looked at this thread?

hello dan,
it seems like i’m having the same problem with my login script.
this is the script i’m using :

function login(email, password, callback) {
  //this example uses the "pg" library
  //more info here: https://github.com/brianc/node-postgres

  const bcrypt = require('bcrypt');
  const postgres = require('pg');

  const conString = 'postgres://*****:*****@7.tcp.eu.ngrok.io:13176/postgres';
  postgres.connect(conString, function (err, client, done) {
    if (err) return callback(err);

    const query = 'SELECT id, name, email, password FROM users WHERE email = $1';
    client.query(query, [email], function (err, result) {
      // NOTE: always call `done()` here to close
      // the connection to the database
      done();

      if (err || result.rows.length === 0) return callback(err || new WrongUsernameOrPasswordError(email));

      const user = result.rows[0];

      bcrypt.compare(password, user.password, function (err, isValid) {
        if (err || !isValid) return callback(err || new WrongUsernameOrPasswordError(email));

        return callback(null, {
          user_id: user.id,
          name: user.name,
          email: user.email
        });
      });
    });
  });
}

Hi @montassar,

Are you seeing the exact same error as OP?

yes, it’s the same error :

“Unknown authenticationOk message typeMessage { name: ‘authenticationOk’, length: 23 }”

Are you able to connect to the DB from another client?

hi dan,
i tried connecting from another client and it worked fine. seems like i have this problem only with auth0.

hello @dan.woda,
i tried working with ElephantSQL and everything worked fine with their DB url. It seems like the problem is with ngrok but i still can’t find a solution.

@montassar,

Have you been able to connect to the DB from a client that is external to your DB’s network? This error seems to be coming from the DB client, which suggests Auth0 has little control over it.

You could try running that same action script in a serverless function.

Hello @dan.woda,
I just fixed it !
Anyone having the same error and looking for a solution, it’s a problem related to your postgresql DB.
All you have to do is
1- open pg_hba.conf ( which is located under C:\Program Files\PostgreSQL\14\data ).
2- scroll down to the bottom of the file, there you will find at the end of every line “scram-sha-256”.
3- just change scram-sha-256 with trust, and that’s gonna fix your problem.

1 Like

Thanks for following up!

1 Like