-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'str' object has no attribute 'update' when running get_authentication_events #533
Comments
I just tried and got the same result, testing against myself (so I know I had a login). Here's the method in the Canvas is returning data from |
Nevermind, figured it out. Canvas returns an object with nested Because it's returned as a |
Wow, thank you @bennettscience. Appreciate the insight & prompt response! I'll probably write my own function to get the API call going for now with |
def get_authentication_events(self, **kwargs):
"""
List authentication events for a given user.
:calls: `GET /api/v1/audit/authentication/users/:user_id \
<https://canvas.instructure.com/doc/api/authentications_log.html#method.authentication_audit_api.for_user>`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.authentication_event.AuthenticationEvent`
"""
from canvasapi.authentication_event import AuthenticationEvent
return PaginatedList(
AuthenticationEvent,
self._requester,
"GET",
"audit/authentication/users/{}".format(self.id),
_kwargs=combine_kwargs(**kwargs),
_root="events"
)
canvasapi.user.User.get_authentication_events = get_authentication_events |
Ah, I forgot about I'd do that instead ☝️ . |
Thanks @jessemcbride. Just FYI your patch now triggers I had to go into
return "{} {} ({})".format(self.created_at, self.event_type, self.id) for the object to be formed.
Otherwise it works great and is returning exactly what I need in the object. |
Describe the bug
I'm getting AttributeError: 'str' object has no attribute 'update' when I try to retrieve & process user.get_authentication_events()
To Reproduce
Steps to reproduce the behavior:
Run the following code after setting up Canvas object & retrieving single user
The code stops right before the print statement on the "for" line. get_authentication_events() returns a PaginatedList but it's not iterable for some reason. Unless I'm missing something. Debug logs are showing that it retrieves the data from the REST API once I start the for loop (I can supply that log upon request)
Expected behavior
I should be able to loop through this PaginatedList object like every other PaginatedList object in Canvas API.
Environment information
python --version
): Python 3.10.2pip show canvasapi
):Name: canvasapi
Version: 2.2.0
Summary: API wrapper for the Canvas LMS
Home-page: https://github.com/ucfopen/canvasapi
Author: University of Central Florida - Center for Distributed Learning
Author-email: [email protected]
Additional context
Here is the stack trace (sanitized personal info/paths as much as possible)
The text was updated successfully, but these errors were encountered: