Not able to to solve error 401 from digest authentication

I would like to ask how new relic synthetic handles the digest authentication should have been implemented in the synthetics script , I can easily manage to obtain the response in JSON format by Curl command as below:

curl -X GET -u “validuser:privatepass” --digest “https://cloud.mongodb.com/api/atlas/v1.0/groups/5eb58ea01f0d401c787348614sza/alerts?status=OPEN

On the Synthetics the Code I receiving 401 (I’ve tried many different ways), I let the last 2 methods on the code below:

/**

  • Feel free to explore, or check out the full documentation
  • https://docs.newrelic.com/docs/synthetics/new-relic-synthetics/scripting-monitors/writing-api-tests
  • for details.
    */
    var request = require(‘request’);
    var assert = require(‘assert’);
    const ACCOUNT_ID = $secure.NEW_RELIC_ACCOUNT_ID
    const INSERT_KEY = $secure.NEW_RELIC_INSIGHTS_API_KEY
    const JWT_TOKEN = $secure.JWT_TOKEN
    const PUBLIC_KEY = encodeURIComponent(‘validuser’)
    const PRIVATE_KEY = encodeURIComponent (‘privatepass’)
    var uri = ‘https://’ + PUBLIC_KEY + ‘:’ + PRIVATE_KEY + ‘@cloud.mongodb.com/api/atlas/v1.0/groups/5eb58ea01f0d401c787348614sza/alerts?status=OPEN’;

const DATABASE = [‘TEST’]
const ENV = ‘DEV’

DATABASE.map((database) => {
callApi(database)
})

function callback(error, response, body) {
console.log(body);
}
$http.get({
‘method’:‘GET’,
‘url’: uri,
followRedirect: false
},callback);

function callApi(database) {
var options = {
uri: uri,
//Define query key and expected data type.
headers: {
‘method’:‘GET’,
// ‘requestTraceId’: ‘SyntheticsHealthCheck’,
‘Accept’: ‘application/json’,
‘Authorization’: ‘DigestAuth’,
// ‘PUBLIC_KEY’ : PUBLIC_KEY,
// ‘PRIVATE_KEY’ : PRIVATE_KEY
}
};

function callback (err, response, results){
console.log(uri + " " + database + " returned " + JSON.parse(results).total + " write limit")

function batchAndSend() {

let message = {
“eventType”: “AtlasMongoDBAlerts”,
“Database”: database,
“NumberOfPendingOrders”: JSON.parse(results).metricName,
“Env”: ENV,
}
sendToInsights(message)
}
batchAndSend()

function sendToInsights(logMessages) {
let insights_url = ‘https://insights-collector.newrelic.com/v1/accounts/’+ ACCOUNT_ID +’/events’
request({
method: “POST”,
url: insights_url,
headers: {
‘Content-Type’: ‘application/json’,
“X-Insert-Key”: INSERT_KEY
},
body: JSON.stringify(logMessages)
}, (err, response, body) => {
console.log(body)
console.log(err)
})
}}

$http.get(options,callback);
}

Could you help me what will be the best approach in this contest.