Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Last active November 21, 2019 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zuzannamj/b64df530f065cb4a996d6871d8f4f631 to your computer and use it in GitHub Desktop.
Save zuzannamj/b64df530f065cb4a996d6871d8f4f631 to your computer and use it in GitHub Desktop.
<script runat="server">
Platform.Load("Core","1.1.1");
var authEndpoint = 'https://mcxxxxxxxxxxxxxxxxxxxxxxxxx.auth.marketingcloudapis.com';
var payload = {
client_id: "insert Client Id",
client_secret: "insert Client Secret",
grant_type: "client_credentials"
};
var url = authEndpoint + '/v2/token';
var contentType = 'application/json';
try {
var accessTokenRequest = HTTP.Post(url, contentType, Stringify(payload));
if(accessTokenRequest.StatusCode == 200) {
var tokenResponse = Platform.Function.ParseJSON(accessTokenRequest.Response[0]);
var accessToken = tokenResponse.access_token;
}
} catch (error) {
Write(Stringify(error));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment