Skip to content

Instantly share code, notes, and snippets.

@imtrinity94
Last active March 10, 2023 09:37
Show Gist options
  • Save imtrinity94/d29538649f72565ddf48bc451138d249 to your computer and use it in GitHub Desktop.
Save imtrinity94/d29538649f72565ddf48bc451138d249 to your computer and use it in GitHub Desktop.
validate NSS REST authorization vRO Script [x-www-form-urlencoded]
/**
*
* @param {string} grantType nss.accesskey
* @param {string} accessId
* @param {SecureString} secretKey
* @param {REST:RESTHost} RESTHost NSSHost
* @outputType boolean
*
*/
var inParamtersValues = [];
var content = 'grant_type=' + grantType + '&accesskeyid=' + accessId + '&secretaccesskey=' + secretKey
var request = RESTHost.createRequest("POST", "/auth/token", content);
request.setHeader("Accept", "application/json")
request.contentType = "application/x-www-form-urlencoded";
//execute request
try {
var response = request.execute();
} catch (error) {
System.error('Cannot execute request to NSS. ' + error);
System.getModule("com.telus.utl").sendEmail("Cannot execute request to NSS", error.toString())
}
statusCode = response.statusCode;
System.debug("NSS token request Status code: " + statusCode);
if (statusCode == 200)
return true;
else
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment