From 6f2c7fcd0010bbf5aa42338c179fb8d807eb4851 Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Sat, 31 Jan 2026 00:09:42 +0100 Subject: [PATCH] Add SHA-256 hash logging for access tokens in auth-test and interactive-login scripts --- bin/auth-test.mjs | 4 ++++ bin/interactive-login.mjs | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/auth-test.mjs b/bin/auth-test.mjs index 93b1fce..601a2b6 100755 --- a/bin/auth-test.mjs +++ b/bin/auth-test.mjs @@ -2,6 +2,7 @@ import { ClientSecretCredential } from "@azure/identity"; import { config } from "../config.js"; +import { createHash } from "crypto"; // We need to wrap the async code in an IIFE // Check, authentication using @azure/identity requires a client secret. @@ -19,6 +20,9 @@ if (config.clientSecret) { ); if (token) { console.log("Authentication with client secret successful."); + const hash = createHash("sha256").update(token.token).digest("hex"); + console.log("SHA-256 hash of access token:", hash); + console.log("Token expires on:", new Date(token.expiresOnTimestamp).toISOString()); } else { console.error("Authentication with client secret failed."); process.exit(1); diff --git a/bin/interactive-login.mjs b/bin/interactive-login.mjs index 0b8f268..df72a4d 100755 --- a/bin/interactive-login.mjs +++ b/bin/interactive-login.mjs @@ -1,5 +1,8 @@ +#!/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"]; @@ -17,5 +20,9 @@ try { process.exit(1); } -console.log("Access token acquired:"); -//console.log(token.accessToken); +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);