"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getManagementApiToken = getManagementApiToken;
const node_fetch_1 = __importDefault(require("node-fetch"));
async function getManagementApiToken() {
    const response = await (0, node_fetch_1.default)(`${process.env.AUTH0_ISSUER_BASE_URL}/oauth/token`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            client_id: process.env.AUTH0_M2M_CLIENT_ID,
            client_secret: process.env.AUTH0_M2M_CLIENT_SECRET,
            audience: `${process.env.AUTH0_ISSUER_BASE_URL}/api/v2/`,
            grant_type: 'client_credentials',
        }),
    });
    if (!response.ok) {
        throw new Error('Failed to get management API token');
    }
    const data = await response.json();
    return data.access_token;
}
//# sourceMappingURL=authM2MToken.js.map