简体   繁体   English

Lambda function 未通过 Auth0 node-auth0 SDK 调用 auth0 方法

[英]Lambda function not calling auth0 methods via Auth0 node-auth0 SDK

I've got a lambda function which is triggered when a message is added to the SQS queue.我有一个 lambda function 当一条消息添加到 SQS 队列时触发。

The message contains a userId which I was hoping to connect to Auth0 node SDK .该消息包含我希望连接到Auth0 节点 SDK的 userId 。

my GetUserDetails (below) fires as the console.log is viewable in CloudWatch我的GetUserDetails (如下)在 CloudWatch 中可以查看console.log时触发

I can see in the Auth0 logs that a token request is made from the new ManagementClient call but then nothing after that.我可以在 Auth0 日志中看到一个令牌请求是new ManagementClient调用发出的,但之后什么也没有。

example of my code我的代码示例

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;
  });
};

I got it to work using this format:我让它使用这种格式工作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM