Skip to content

Instantly share code, notes, and snippets.

Created March 2, 2018 15:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple password ServiceNow API authentication in Google script.
function SNOWsimpleAuth() {
// Those are environnement variables defined in File>Project properties>Script properties
var username = PropertiesService.getScriptProperties().getProperty('LOGIN');
var password = PropertiesService.getScriptProperties().getProperty('PASSWORD');
// I will use Google script UrlFetchApp class to make request, which is more powerfull than XMLHttpRequest
var headers = {
'Authorization': 'Basic ' + Utilities.base64Encode(username + ":" + password)
var options = {
'method' : 'get',
'accept': 'application/json',
// Let's query the first incident of a SNOW testing developper instance
var response = UrlFetchApp.fetch("", options);
Logger.log("caught this:" + e);
Logger.log("Before JSON parsed "+ response.getContentText());
var responseBody = JSON.parse(response.getContentText())['result'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment