Retrieve Canvas ID and SIS User ID using User ID in Canvas LMS

Jump to solution
nasir-discourse
Community Member

"During the LTI launch, I am receiving the following parameters:

  • canvas_id
  • sis_user_id
  • login_id
  • global_canvas_id
  • user_id

The user_id is in this format: "9dfd5a225d8c9dacba7302c095df431b5e40fb63," which I initially saved in the database. Is there any API call in Canvas or any other method to retrieve the canvas_id or sis_user_id using this user_id?"

0 Likes
1 Solution
matthew_buckett
Community Contributor

The user_id in an LTI launch can be looked up by using the special prefixed as outlined in: https://canvas.instructure.com/doc/api/file.object_ids.html

If you're getting the ID through a LTI 1.1 launch then you can use a prefix of 'lti_1_1_id:' so to lookup the user_id from your example you'd make an API request (with an token) to https://inst.instructure.com/api/v1/users/lti_1_1_id:9dfd5a225d8c9dacba7302c095df431b5e40fb63 and it should return details of the user.

NB: This doesn't work for everyone, if someone access your Canvas instance who you can't view details of it will fail, an example of this is Instructure Support when they access a tool. They can access your instance, but a token that you use to lookup details won't find anything. But these users are very rare in most cases.

View solution in original post