【问题标题】:Lambda function not calling auth0 methods via Auth0 node-auth0 SDKLambda 函数未通过 Auth0 node-auth0 SDK 调用 auth0 方法
【发布时间】:2020-03-03 10:05:16
【问题描述】:

我有一个 lambda 函数,当消息添加到 SQS 队列时会触发该函数。

该消息包含我希望连接到 Auth0 node SDK 的 userId。

console.log 在 CloudWatch 中可见时,我的 GetUserDetails(下)会触发

我可以在 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;
  });
};

【问题讨论】:

    标签: javascript node.js aws-lambda auth0


    【解决方案1】:

    我让它使用这种格式工作:

    auth0
      .getUser(userId)
      .then(function(users) {
        console.log(users);
      })
      .catch(function(err) {
        console.log(err);
      });
    

    【讨论】:

    • 嗨,丹,您是否在快速服务器或类似的服务器或 lambda 函数中运行此程序?正如我刚刚做的一样,没有任何控制台记录
    猜你喜欢
    • 2018-08-27
    • 2017-07-01
    • 2017-02-27
    • 2017-06-02
    • 2019-01-13
    • 2019-12-11
    • 2018-06-10
    • 2021-04-21
    • 1970-01-01
    相关资源
    最近更新 更多