javascript - Lambda 函数未通过 Auth0 node-auth0 SDK 调用 auth0 方法
问题描述
我有一个 lambda 函数,它在将消息添加到 SQS 队列时触发。
该消息包含我希望连接到Auth0 节点 SDK的 userId 。
在 CloudWatch 中可以看到我的GetUserDetails
(下)触发console.log
我可以在 Auth0 日志中看到来自调用的令牌请求,new ManagementClient
但之后没有任何内容。
我的代码示例
import { ManagementClient } from 'auth0';
const auth0 = new ManagementClient({
domain: 'xxx.auth0.com',
clientId: 'xxx',
clientSecret: 'xxx',
scope: 'read:users update:users',
});
const GetUserDetails = userId => {
console.log('userId', userId); <-- This fires and can be seen in CloudWatch
auth0.getUser({ id: userId }, (err, resp) => { <-- Nothing happens no errors, no user details
if (err) {
console.log('my error', err);
return err.message;
}
console.log(resp);
return resp;
});
};
解决方案
我让它使用这种格式工作:
auth0
.getUser(userId)
.then(function(users) {
console.log(users);
})
.catch(function(err) {
console.log(err);
});
推荐阅读
- c - project.c:43:68: 错误:在 '->' 标记之前需要 '='、','、';'、'asm' 或 '__attribute__'
- c++ - C++ function_pointer 和 &function_pointer 有什么区别?
- python - 使用 pop 更新嵌套的 Python 列表键
- java - Java在句子后添加新行(为什么要双新行来解决它)?
- javascript - ES6 处理剩余的对象解构(对象修剪)
- security - 如何找到生成的openssl密钥的页眉和页脚以及公钥的值是什么
- angular - 防止 ngFor 中子组件的数据绑定
- kotlin - 在 Vert.x 的 service-proxy 中使用 Kotlin 的数据类
- python - 如何在年度时间序列中获得所有年份的 7 月?(Jupyter 笔记本)
- java - 如何在 JPanel 的所有组件上绘制一些东西