const require_fetcher = require('../fetcher.cjs');
const require_built = require('../config/dist/esm/built.cjs');

//#region ../api/dist/esm/getIntlayerAPI/oAuth.mjs
const getOAuthAPI = (intlayerConfig) => {
	const backendURL = intlayerConfig?.editor?.backendURL ?? require_built.built_default?.editor?.backendURL;
	const { clientId, clientSecret } = intlayerConfig?.editor ?? {};
	if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
	/**
	* Gets an oAuth2 accessToken
	* @return The token information
	*/
	const getOAuth2AccessToken = async (otherOptions = {}) => await require_fetcher.fetcher(`${backendURL}/oauth2/token`, {}, otherOptions, {
		method: "POST",
		headers: { "Content-Type": "application/x-www-form-urlencoded" },
		body: {
			grant_type: "client_credentials",
			client_id: clientId,
			client_secret: clientSecret
		}
	});
	return { getOAuth2AccessToken };
};

//#endregion
exports.getOAuthAPI = getOAuthAPI;
//# sourceMappingURL=oAuth.cjs.map