Last active
October 1, 2020 13:48
-
-
Save zuzannamj/40f01efd553a08335c9d73c444fe80df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat="server"> | |
Platform.Load("Core","1.1.1"); | |
var authEndpoint = 'https://mcxxxxxxxxxxxxxxxxxxxxxxxxx.auth.marketingcloudapis.com'; | |
var payload = { | |
clientId: "insert Client Id", | |
clientSecret: "insert Client Secret" | |
}; | |
var url = authEndpoint + '/v1/requestToken'; | |
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.accessToken; | |
} | |
} catch (error) { | |
Write(Stringify(error)); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment