クライアントシークレットのローテーション(定期更新)ポリシー適用に伴い、Marketing Cloud Engagement の管理者は、どの外部プラットフォームやツールが自身のアカウントとアクティブに連携しているかを把握する必要があります。
REST API の「セキュリティイベント監査エンドポイント」を使用することで、管理者は外部ツールが Marketing Cloud API を利用した正確な場所と日時を特定できます。このソース IP アドレスとイベントのタイムスタンプを把握することにより、管理者はインバウンド呼び出しを行っている特定のサードパーティ統合、ミドルウェア、または外部アプリケーションを明確に突き止めることが可能です。このデータにより、どのプラットフォームに新しいクライアントシークレットを更新すべきかを正確に把握できるため、ローテーション作業中の予期せぬシステム停止を防ぐことができます。
重要な要件: このエンドポイントを使用するには、Marketing Cloud Engagement テナント内で 監査証跡(Audit Trail)機能が有効化されている必要があります。アカウントで監査証跡がまだアクティブになっていない場合、API がセキュリティイベントデータを返せるようにするため、管理者が 設定(Setup) から有効 にする必要があります。
セキュリティイベントの監査ペイロードを抽出し、ターゲットデータエクステンション(DE)へ自動的にデータを追加するには、以下の手順を実行します。
Marketing Cloud Engagement, で Email Studio > すべての購読者 > データエクステンション へ遷移
Audit_SecurityEvents_DE という名前とキーを指定しデータエクステンションを作成 (送信可能ではない).
以下のフィールドを設定:
| Field Name | Data Type | Length | Nullable | Notes |
| createddate | Date | N/A | Checked | イベント発生日時 |
| mid | Text | 50 | Checked | イベントが発生したMID |
| IPaddress | Text | 254 | Checked | 呼び出し元 IP |
| employeename | Text | 254 | Checked | API ユーザ名 (例., "oAuth2.1 app user"). |
| loginstatus | Text | 100 | Checked | 成功有無 |
注意: このスクリプトを毎日の自動実行(日次オートメーション)で運用する場合は、重複登録を防ぐための設定を検討してください。重複する時間枠のデータが入るのを防ぐため、自動採番(自動インクリメント)フィールドを追加するか、ペイロード内の
idフィールドを主キー(Primary Key)としてマッピングすることをおすすめします。
セットアップ > アプリ > インストール済みパッケージ へ遷移
サーバー間 (Server-to-Server) API 連携 コンポーネントを持つパッケージを選択または新規作成.
選択されたパッケージに Tracking Events > Read 権限が付与されていることを確認.
クライアント ID と クライアントシークレットと, テナント固有のサブドメインを手元にコピー.
Journey Builder > Automation Studio へ遷移.
新しいオートメーションを作成
Script Activity をワークフローのキャンバスにドラッグ.
下記 SSJS コードブロックをコピーして Script Activity コードを作成.
tenant subdomain, Client Id, と Client Secret をStep2-4 でコピーした文字列に修正
保存後 Automation を実行.
<script runat="server">
Platform.Load("Core", "1.1.5");
// Helper function to format dates to ISO 8601 strings for the REST API
function getISO8601String(d) {
var pad = function(n) { return n < 10 ? '0' + n : n; };
return d.getUTCFullYear() + '-' +
pad(d.getUTCMonth() + 1) + '-' +
pad(d.getUTCDate()) + 'T' +
pad(d.getUTCHours()) + ':' +
pad(d.getUTCMinutes()) + ':' +
pad(d.getUTCSeconds()) + 'Z';
}
try {
// 1. Configure Credentials
var tenantSubdomain = "{{et_subdomain}}"; // Replace with your tenant subdomain
var clientId = "YOUR_CLIENT_ID"; // Replace with Client ID
var clientSecret = "YOUR_CLIENT_SECRET"; // Replace with Client Secret
var targetDEKey = "Audit_SecurityEvents_DE";
// 2. Authenticate to get the REST Access Token
var authEndpoint = "https://" + tenantSubdomain + ".auth.marketingcloudapis.com/v2/token";
var authPayload = {
"grant_type": "client_credentials",
"client_id": clientId,
"client_secret": clientSecret
};
var authReq = new Script.Util.HttpRequest(authEndpoint);
authReq.emptyContentHandling = 0;
authReq.retries = 2;
authReq.continueOnError = true;
authReq.contentType = "application/json";
authReq.method = "POST";
authReq.postData = Stringify(authPayload);
var authResp = authReq.send();
var accessToken = "";
if (authResp.statusCode == 200) {
var authJSON = Platform.Function.ParseJSON(String(authResp.content));
accessToken = authJSON.access_token;
} else {
throw "Failed to authenticate with Marketing Cloud API. Status: " + authResp.statusCode;
}
// 3. Calculate Date Parameters (Past 7 Days)
var endDate = new Date();
var startDate = new Date();
startDate.setDate(startDate.getDate() - 7);
var endDateStr = encodeURIComponent(getISO8601String(endDate));
var startDateStr = encodeURIComponent(getISO8601String(startDate));
// 4. Initialize Data Extension and Loop Control
var targetDE = DataExtension.Init(targetDEKey);
var pageSize = 100;
var page = 1;
var keepFetching = true;
while (keepFetching) {
// Construct endpoint using current page index and date filters
var auditEndpoint = "https://" + tenantSubdomain + ".rest.marketingcloudapis.com/data/v1/audit/securityEvents"
+ "?startDate=" + startDateStr
+ "&endDate=" + endDateStr
+ "&$pagesize=" + pageSize
+ "&$page=" + page;
var req = new Script.Util.HttpRequest(auditEndpoint);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", "Bearer " + accessToken);
req.method = "GET";
var resp = req.send();
if (resp.statusCode == 200) {
var result = Platform.Function.ParseJSON(String(resp.content));
var items = result.items || [];
// If a page returns empty, we have retrieved all records for the timeframe
if (items.length === 0) {
keepFetching = false;
break;
}
for (var i = 0; i < items.length; i++) {
var item = items[i];
// Navigate nested 'employee' object safely
var empName = "";
if (item.employee && item.employee.employeeName) {
empName = item.employee.employeeName;
}
// Define the GUID regex pattern (case-insensitive)
var guidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
var hasGuid = guidRegex.test(empName);
// Filter IN "app user" but explicitly skip strings that contain a system GUID
if (empName.toLowerCase().indexOf("app user") !== -1 && !hasGuid) {
// Navigate nested 'loginStatus' object safely
var statusName = "";
if (item.loginStatus && item.loginStatus.name) {
statusName = item.loginStatus.name;
}
// Map fields exactly to your Data Extension schema
var row = {
"createddate": item.createdDate,
"mid": item.memberId,
"IPaddress": item.ipAddress,
"employeename": empName,
"loginstatus": statusName
};
// Add the record to the Data Extension
try {
targetDE.Rows.Add(row);
} catch (deError) {
logError("Failed to insert row for ID " + item.id + ": " + Stringify(deError));
}
}
}
// Advance to the next page of results
page++;
} else {
keepFetching = false;
throw "Error retrieving data from the Audit API. Status Code: " + resp.statusCode;
}
}
} catch (error) {
logError("Critical Script Exception: " + Stringify(error));
}
function logError(message) {
Write(message + "\n");
}
</script>
スクリプトアクティビティの実行が完了したら、ターゲットデータエクステンションを確認します。IPaddress と createddate の列を確認して、外部ツールが「いつ・どこから」API 呼び出しを行っているかを正確に把握します。この記録された監査ログを活用して連携システムの所有者と更新日時を調整し、稼働中の API 接続を中断することなくクライアント認証情報のローテーションを円滑に導入します。
005388368

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.