We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

J_Matsumoto's avatar
J_Matsumoto
Explorer | Level 4
8 years ago
Solved

Confirmation of audit log

I'd like to check the audit log using python module.

 

TEAM_AUDIT_TOKEN = 'xxxxxxx'
dbx_team = dropbox.DropboxTeam(TEAM_AUDIT_TOKEN)
dbx_user = dbx_team.as_user("dbmid:xxxxxx")
end_time = dt.datetime.now()
start_time = end_time - dt.timedelta(hours=2)
check_times = dropbox.team_common.TimeRange(start_time,end_time)
res = dbx_user.team_log_get_events(
limit=None,
account_id=None,
time=check_times,
category=dropbox.team_log.EventCategory.logins)



It's possible to acquire below.

GetTeamEventsResult(events=None, cursor='xxxxxxxxxxxxxx, has_more=False)

I want you to tell me how log can be acquired after this.

  • Greg-DB's avatar
    Greg-DB
    8 years ago

    It looks like the issue is the timezone that datetime.now is using by default. When interacting with the API, you should use UTC. So, instead of:

     

    end_time = dt.datetime.now()

     

    you can use:

     

    end_time = dt.datetime.utcnow()

     

4 Replies

  • J_Matsumoto's avatar
    J_Matsumoto
    Explorer | Level 4
    8 years ago

    Is time of the log record late for 24 hours?


    start_time = end_time - dt.timedelta(hours=33)

     

    (24 hours before, +JST-9:00)

     

    If it was changed, it could be acquired.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    It looks like the issue is the timezone that datetime.now is using by default. When interacting with the API, you should use UTC. So, instead of:

     

    end_time = dt.datetime.now()

     

    you can use:

     

    end_time = dt.datetime.utcnow()

     

  • J_Matsumoto's avatar
    J_Matsumoto
    Explorer | Level 4
    8 years ago

    Greg

     

    I'm very thankful.

    Can the present designation audit log be acquired only after 24 hours?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    I'm not sure I understand your question. Can you elaborate? There shouldn't be any significant delay on the audit log, and you can request it whenever you want, for whatever time range you want.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,035 PostsLatest Activity: 5 hours ago
410 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!