Canvas User Id in LTI Request when Teacher is in Student View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Step to peproduce:
- Open a fresh browser session
- Login to Canvas
- Go to Course (that you are a teacher role of), Settings, Student View
- Go to an LTI tool
At this point the Canvas sends a LTI tool launch request to the tool provider, and one of the request parameters is the canvas user id ("custom_canvas_user_id").
And in the case of student view, this user id will be the "Test Student" user id not the staff's user id.
That on its own is not an issue, the issue is calling Canvas API GET /v1/users/{id} does not work on this user id. It returns 401 unauthorized even if the canvas token is from an Account Admin.
I have the following questions:
- How to reliably tell if an user id belongs to a Test Student?
- From our observation, Each course has it's own Test Student, is this correct?
- How to use Canvas API to find out the user id of the Test Student for a given course?
- Why is Canvas API calls not work on Test Student user id?
Also fun fact, if you open Canvas Live API in the same browser session as your canvas website, then somehow the API page is taking on the context of the Canvas website.
Ie. When the teacher enters the student view of a course, your Live API page is also entering that student view mode.
Meaning you can not query another course, you cant query any user, you can query current course but the enrollments return dummy students instead of real data.
This is even when the Canvas token you apply to the Live API page is not from the same user who log in to the Canvas website.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue has now been resolved.
- GET /v1/users/{id} now works for Test Student user ID.
- There is a Canvas API to query test student(s) for a given course:
GET /v1/courses/{course_id}/users
E.g. https://auckland.test.instructure.com:443/api/v1/courses/13388/users?enrollment_type[]=student_view