Welcome to the new Box Support website. Check out all the details here on what’s changed.

Can not get User event log by using JWTAuth

New post

Comments

2 comments

  • kendomen

    We get all events for all users using enterprise events as a JWT AutomationUser using Azure Functions but if you want to get user events, you can do this...

     

    var adminClient = sdk.getAppAuthClient('enterprise', ENTERPRISE_ID);
    
    // At this point, I'm just a JWT AutomationUser
    adminClient.users.get(adminClient.CURRENT_USER_ID, null, function(err, currentUser) {
      if(err) throw err;  console.log('Hello, ' + currentUser.name + '!');
    });
    
    // So you can get a particular user and call functions as that user
    adminClient.enterprise.getUsers({filter_term: "ken.domen@nike.com"}, function (err, users) { 
      var userId = users.entries[0].id;
      var appUserClient = sdk.getAppAuthClient('user', userId);
      
      appUserClient.events.get(null, function(err, events) {
        events.entries.forEach(function(event) {
          console.log(event);
        }, this);
      });
    });

     

    0
    Comment actions Permalink
  • thanhdangminh36

    Thank for you quick response.

    In Python, base on your code, I was tried to get enteprise user and I can get user event log sucessfully.

    Here is my code.

     

    auth = JWTAuth(
    client_id='xxxxxxxxxxxxxxxxxxxxxx',
    client_secret='xxxxxxxxxxxxxxxxxxxxxxxx',
    enterprise_id='0000000',
    jwt_key_id='yyyyyyy',
    rsa_private_key_file_sys_path='oauth\private.pem',
    store_tokens=callback_token
    )

    auth.authenticate_instance()
    client = Client(auth)
    auth.authenticate_app_user(client.user("***email address removed for privacy***))

    I don't know it is the best way or not, I will try out more.

    The big thanks for your help.

    0
    Comment actions Permalink

Please sign in to leave a comment.