duosecurity / duo_client_python

Python library for interacting with the Duo Auth, Admin, and Accounts APIs
https://duo.com/docs/
Other
136 stars 136 forks source link

Getting "Received 429 Too Many Requests" for auth logs even if hitting the API in 6-7 minute intervals #240

Open agafonoo opened 1 year ago

agafonoo commented 1 year ago

Description

I am using the Duo client to get auth logs in roughly 6-7 minute intervals. The project is in development and once deployed that interval will be measured in hours.

Expected Behavior

Using

admin_api.get_authentication_log(api_version=2, kwargs=params, users=user_ids)

I would expect to get the logs back.

Actual Behavior

Screenshot from 2023-10-30 10-12-56

I get the "429" error instead.

Screenshot from 2023-10-30 10-25-12

Steps to Reproduce

You can try to reproduce with this chunk of code:

def get_duo_user_ids(admin_api, usernames):
    user_ids = []

    try:
        user_info = admin_api.get_users_by_names(usernames)
        for user in user_info:
            user_ids.append(user["user_id"])
    except (NameError, TypeError) as error: 
        print(error)

    return user_ids

def get_authentication_duo_log(self, admin_api, user_ids):
    params = {}
    params["limit"] = 1000

    try:
        auth_logs = admin_api.get_authentication_log(api_version=2, kwargs=params, users=user_ids)
    except (NameError, TypeError) as error: 
        print(error)
    return auth_logs

I have the latest version of the client installed.

Screenshot from 2023-10-30 10-30-59