the idea is to connect to an external system from NS and get the token from https response. First of all, I converted the couple (login, password) to the base64,then I created a header contain the param of authorization in a specific format, and finally I send my https request . But the response code returned is 406 and not 200 :/ .
Below an exemple of the structure of my code
var stringInput = "email:password";
var base64EncodedString = encode.convert({
string: stringInput,
inputEncoding: encode.Encoding.UTF_8,
outputEncoding: encode.Encoding.BASE_64
});
var auth = 'Basic ' + base64EncodedString;
var _headers = false;
_headers = {
Authorization: auth
};
var url_ = 'https:/..../api/auth/token';
var auth_resp = https.get({
url: url_,
headers: _headers
});
if (auth_resp.code == 200) {
return JSON.parse(auth_resp.body);
}
Have you any idea about that! and Thanks a lot :D