我正在尝试在 NodeJS 中使用 Azure 身份验证推送一个无输入电视屏幕仪表板(使用 chromecast)( working fine without auth so far )
我最好的举动(?)是使用 ms-rest-azure 包,允许使用 https://aka.ms/devicelogin 从另一台设备执行初始身份验证& 代码
但是,是否有一种干净的方法来检索此代码并使其在控制台之外可用?我找不到引用或回调。
我的后备方案是拦截process.stdout.write
,但感觉很脏。
最佳答案
有一个选项对象可以传递给interactiveLogin。一个选项是“userCodeResponseLogger”,它应该是一个函数,例如
let options = {"userCodeResponseLogger":(msg)=>{
console.log("I have the message",msg)
}
}
msRestAzure.interactiveLogin(options).then((credentials) => {
// doing authentication stuff
});
请注意,您仍然需要解析消息以提取代码。
关于node.js - 使用 InteractiveLogin 方法检索 ms-rest-azure 身份验证代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48851884/