I am trying to run the below script from Python.
import execjs
var request = require('request');
var apiHostName='https:/url.com';
emailAddress = 'my.email@company.com'
apiKey = 'api_key'
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log("Identity with email address " + emailAddress + " found:");
var b= JSON.parse(body);
console.log("id="+b.identityId+",api key="+b.apiKey+",type="+b.type);
} else{
if (response.statusCode == 401) {
console.log ("Couldn't recognize api key="+apiKey);
} else if (response.statusCode == 403) {
console.log ("Operation forbidden for api key="+apiKey);
} else if (response.statusCode == 404) {
console.log ("Email address " +emailAddress + " not found");
}
}
}
I did this:
pip install py-mini-racer
pip install PyExecJS
I would think this is pretty close, based on the research that I did, but I don't know for sure. All I'm getting now is this error: 'SyntaxError: invalid syntax'
The error occurs on this line: 'var request = require('request');'
Obviously, I am using my actual email and api key. I am running Python 3.x.