Added interactive login prototype.
This commit is contained in:
28
src/prototypes/interactive-login.mjs
Normal file
28
src/prototypes/interactive-login.mjs
Normal file
@@ -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);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user