diff --git a/src/prototypes/interactive-login.mjs b/src/prototypes/interactive-login.mjs new file mode 100644 index 0000000..2f84157 --- /dev/null +++ b/src/prototypes/interactive-login.mjs @@ -0,0 +1,28 @@ +import { loginInteractive } from "sk-az-tools/azure"; + +const config = { + tenantId: "ce45d437-ed75-4a4f-9d57-87e1ef73f8d6", + clientId: "187960e4-499e-4334-95ec-70a9d70cbd3a", +}; + +async function main() { + const graphApiToken = await loginInteractive({ + tenantId: config.tenantId, + clientId: config.clientId, + scopes: ["https://graph.microsoft.com/.default"], + }); + + const accessToken = graphApiToken?.accessToken; + + if(!accessToken) { + throw new Error("Failed to obtain Microsoft Graph API token"); + } + + console.log("Successfully obtained Microsoft Graph API token."); +} + +main().catch((err) => { + console.error("An error occurred:"); + console.error(err); + process.exit(1); +});