this script, trying to get a API token but not sure if this is correct, Google has so many different options, its all over the place and documentation is lacking... I replaced my API values with XXX.
<script runat="server">
Platform.Load("Core", "1");
try {
Write("<br>Step 1: Starting Authentication");
// STEP 1: Authenticate and retrieve the access token
var clientId = "XXXX"; // Replace with your actual Client ID
var clientSecret = "XXXX"; // Replace with your actual Client Secret
var authUrl = "https://XXXXXXXX-vt8.auth.marketingcloudapis.com/v2/token";
var authPayload = {
"client_id": clientId,
"client_secret": clientSecret,
"grant_type": "client_credentials"
};
Write("<br>Step 1: Sending HTTP POST Request");
var authRequest = HTTP.Post(authUrl, "application/json", Stringify(authPayload));
// Directly parse the response and retrieve the token
Write("<br>Step 1: Received Authentication Response");
var authResponse = Platform.Function.ParseJSON(authRequest.Response);
var accessToken = authResponse.access_token;
// Log the access token for debugging
Write("<br>Access Token Retrieved Successfully: " + accessToken);
} catch (e) {
Write("<br>Exception: " + e.toString());
}
</script>
the output is:
Step 1: Starting Authentication
Step 1: Sending HTTP POST Request
Step 1: Received Authentication Response
Exception: TypeError: Unable to retrieve security descriptor for this frame.
I know the API is setup right with the right permission as I did a CURL test and it worked, but can't seem to get the Script right, thanks!