Create vraLogout.js

This commit is contained in:
John Bowdre 2022-06-14 08:49:12 -05:00 committed by GitHub
parent c16c6a54f2
commit f26ef563bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,14 @@
/* JavaScript: vraLogout action
Logs out of a connected vRA REST endpoint.
Inputs: token (string)
Return type: string
*/
var host = System.getModule("com.virtuallypotato.utility").getConfigValue("vPotato", "Endpoints", "vRAHost").host;
var logoutObj = {
idToken: token
};
var logoutJson = JSON.stringify(logoutObj);
var request = host.createRequest("POST", "/csp/gateway/am/api/auth/logout", logoutJson);
request.setHeader("Content-Type", "application/json");
request.execute().statusCode;
System.debug("Terminated vRA API session: " + token);