node.js - 使用 InteractiveLogin 方法检索 ms-rest-azure 身份验证代码

标签 node.js azure

我正在尝试在 NodeJS 中使用 Azure 身份验证推送一个无输入电视屏幕仪表板(使用 chromecast)( working fine without auth so far )

我最好的举动(?)是使用 ms-rest-azure 包,允许使用 https://aka.ms/devicelogin 从另一台设备执行初始身份验证& 代码 enter image description here

但是,是否有一种干净的方法来检索此代码并使其在控制台之外可用?我找不到引用或回调。

我的后备方案是拦截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/

相关文章:

Azure Kudu 工具栏缺少菜单项

design-patterns - 如何设计游戏服务器的通信 channel

javascript - 具有特定值的 Mongoose 模式属性

javascript - 导入时baseUrl和node_modules之间的冲突

c# - Sitecore azure 无法启动

Azure:如何创建 WADLogsTable 来捕获诊断代码?

javascript - 在 Node js中将JSON.gz转换为JSON

javascript - 如何在node.js中读取多部分表单

Windows Azure : how to measure the execution time of a code

windows - Blob容器创建异常