Files
azure-node-playground/bin/interactive-login.mjs

29 lines
739 B
JavaScript
Executable File

#!/usr/bin/env node
import { loginInteractive } from "../src/auth.js";
import { config } from "../public-config.js";
import { createHash } from "crypto";
const scopes = ["https://management.azure.com/.default"];
let token;
try {
token = await loginInteractive({
tenantId: config.tenantId,
clientId: config.clientId,
scopes,
});
} catch (e) {
console.error("Login failed:", e);
console.error(e.stack);
process.exit(1);
}
console.log("Access token acquired.");
// Print SHA-256 hash of the access token for verification purposes
const hash = createHash("sha256").update(token.accessToken).digest("hex");
console.log("SHA-256 hash of access token:", hash);
console.log("Token expires on:", token.expiresOn);