Last active
April 6, 2020 09:17
-
-
Save zuzannamj/927703d05448a09b01f36b259ed28b11 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
//authenticate to get access token | |
var authEndpoint = 'https://mcxxx.auth.marketingcloudapis.com/' //provide API endpoint | |
var payload = { | |
client_id: "xxxxxx", //pass Client ID | |
client_secret: "xxxxxx", //pass Client Secret | |
grant_type: "client_credentials" | |
}; | |
var url = authEndpoint + '/v2/token' | |
var contentType = 'application/json' | |
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 | |
var rest_instance_url = tokenResponse.rest_instance_url | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment