Canvas User Id in LTI Request when Teacher is in Student View

Jump to solution
d_tan
Community Participant

Step to peproduce:

  1. Open a fresh browser session
  2. Login to Canvas
  3. Go to Course (that you are a teacher role of), Settings, Student View
  4. 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.

Labels (2)
1 Solution
d_tan
Community Participant
Author

This issue has now been resolved.

View solution in original post