Identify MuckRock in calls to Accounts and DocumentCloud#2181
Open
duckduckgrayduck wants to merge 2 commits into
Open
Identify MuckRock in calls to Accounts and DocumentCloud#2181duckduckgrayduck wants to merge 2 commits into
duckduckgrayduck wants to merge 2 commits into
Conversation
cbed0b6 to
b3d9798
Compare
Contributor
Author
|
In python manage.py shell in deploy preview I tested Tested:
Not tested (complicated to test and there are no functional differences in the client, so I don't think it is necessary).
Can see that the user agent works on DocumentCloud here. Squarelet staging isn't proxied behind Cloudflare so we can't see it there, but in heroku logs you can see that the user agent is set there as well. |
eyeseast
reviewed
May 21, 2026
| def get_dc_client(): | ||
| """Get a DocumentCloud client for the MuckRock User Account""" | ||
| client = DocumentCloud( | ||
| username=settings.DOCUMENTCLOUD_BETA_USERNAME, |
Contributor
There was a problem hiding this comment.
We should rename these settings at some point. Doesn't have to be now.
eyeseast
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We were calling the same DC client in several files and sometimes multiple times in a single file, all using the same user. This consolidates this into one client in core/utils.py that anyone can call in the future to use the MuckRock Accounts service account. The import_to_documentcloud method uses a different client, so I preserved that functionality as-is and documented it as such. It hasn't been re-used yet, so I didn't see a reason to create a helper method for this yet.
This preserves the old user agent (specifying the version of python-requests) and appends a custom user agent we can set in environment variables
This PR also identifies ourselves in calls to Accounts