Add console-only auth URL option
This commit is contained in:
@@ -53,7 +53,12 @@ async function acquireTokenWithCache({ pca, scopes }) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginInteractive({ tenantId, clientId, scopes }) {
|
export async function loginInteractive({
|
||||||
|
tenantId,
|
||||||
|
clientId,
|
||||||
|
scopes,
|
||||||
|
showAuthUrlOnly = false,
|
||||||
|
}) {
|
||||||
if (!tenantId) throw new Error("tenantId is required");
|
if (!tenantId) throw new Error("tenantId is required");
|
||||||
if (!clientId) throw new Error("clientId is required");
|
if (!clientId) throw new Error("clientId is required");
|
||||||
if (!Array.isArray(scopes) || scopes.length === 0)
|
if (!Array.isArray(scopes) || scopes.length === 0)
|
||||||
@@ -67,20 +72,27 @@ export async function loginInteractive({ tenantId, clientId, scopes }) {
|
|||||||
return await pca.acquireTokenInteractive({
|
return await pca.acquireTokenInteractive({
|
||||||
scopes,
|
scopes,
|
||||||
openBrowser: async (url) => {
|
openBrowser: async (url) => {
|
||||||
try {
|
if (showAuthUrlOnly) {
|
||||||
await open(url, { wait: false });
|
console.log("Visit:\n" + url);
|
||||||
// To enforce Microsoft Edge instead of the default browser, use:
|
return;
|
||||||
// await open(url, {
|
}
|
||||||
// wait: false,
|
|
||||||
// app: {
|
// To enforce Microsoft Edge instead of the default browser, use:
|
||||||
// name: apps.edge,
|
// return open(url, {
|
||||||
// },
|
// wait: false,
|
||||||
// });
|
// app: {
|
||||||
} catch {
|
// name: apps.edge,
|
||||||
|
// },
|
||||||
|
// }).catch(() => {
|
||||||
|
// // If auto-open fails, provide URL for manual copy/paste.
|
||||||
|
// console.log("Visit:\n" + url);
|
||||||
|
// });
|
||||||
|
|
||||||
|
return open(url, { wait: false }).catch(() => {
|
||||||
// If auto-open fails, provide URL for manual copy/paste.
|
// If auto-open fails, provide URL for manual copy/paste.
|
||||||
console.log("Visit:\n" + url);
|
console.log("Visit:\n" + url);
|
||||||
}
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user