Auth0 Home Blog Docs

Unauthorized 401 with Azure SQL



I am doing some testing in regards to importing users from my current database(Azure SQL). I have set all my connection settings as needed and also added the IP Addresses to my Azure SQL firewall, but still receiving Unauthorized 401 error when i try to check the connections using Auth0 provided UI.

Some help will be much appreciated.

Kind Regards,


Below is my Database Action Script:
function login(email, password, callback) {

  var Connection = require('tedious@1.11.0').Connection;
  var Request = require('tedious@1.11.0').Request;
  var TYPES = require('tedious@1.11.0').TYPES;

  var connection = new Connection({
    userName: 'username',
    password: 'password',
    server: 'server',
    options: {
      database: 'database',
      encrypt: true,

  var query = "SELECT Id, Email, Password " +
    "FROM dbo.User WHERE Email = @Email";

  connection.on('debug', function (text) {
    // Uncomment next line in order to enable debugging messages
  }).on('errorMessage', function (text) {
    console.log(JSON.stringify(text, null, 2));
    return callback(text);
  }).on('infoMessage', function (text) {
    // Uncomment next line in order to enable information messages
    console.log(JSON.stringify(text, null, 2));

  connection.on('connect', function (err) {
    if (err) { return callback(err); }

    var request = new Request(query, function (err, rowCount, rows) {
      if (err) {
        callback(new Error(err));
      } else if (rowCount < 1) {
        callback(new WrongUsernameOrPasswordError(email));
      } else {, rows[0][2].value, function (err, isValid) {
          if (err) { callback(new Error(err)); }
          else if (!isValid) { callback(new WrongUsernameOrPasswordError(email)); }
          else {
            callback(null, {
              user_id: rows[0][0].value,
              email: rows[0][1].value

    request.addParameter('Email', TYPES.VarChar, email);


Hi, i’m having the same issue, have u been able to fix it?


Hi, I am having the same problem. Has the issue been resolved?