Can not get User event log by using JWTAuth
Hi everyone,
I use User A in The Box to control the files and folders.
I create the box app by this user and try to create Cron-job to get user event log automatically in server-side.
I used JWTAuth and authenticate sucessfully but authenrticated user is ***email address removed for privacy*** created automatically. With that user I alsway get event log with no result.
{'entries': [], 'chunk_size': 0, 'next_stream_position': 81642***phone number removed for privacy***}
Because it not a user A I think.
Other way, When I use develop token to authen, I can get all of event logs.
There is any way to get all event logs by JWTAuth user?
-
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); }); });
-
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.
Please sign in to leave a comment.
Comments
2 comments