Hi @JamesSekcienski
Thanks for chiming in, it's really appreciated.
We would be very happy not to use the Canvas REST API in the first place and only stick to LTI but that seems not to be possible. In our tool we want to be able to capture the "sections" present in a Canvas course, along with the students included in each section; Course "Sections" are something that is not part of any LTI specification and as such we were forced to use the Canvas REST API to capture this information. The same holds true for the sections composition (that is, the students that are associated with each section in the course).
The main problem here is that when we query Canvas to retrieve the course sections and their members we don't get a complete "picture" of the students, since their email is missing from the list. I would also be happy to avoid using the email as a unique identifier for the students in this particular flow but here we're hitting another roadblock: The list of students we get from Canvas via the REST API and the list of students we get from LTI Advantage (Names and Roles) are hard to reconcile... LTI Advantage gives us a list of learners with "user_id" that have meaning only inside LTI, while when we query Canvas (via its REST API) we get list of students with "id" that are meaningful inside of that Canvas LMS but (for obvious reasons) don't match the LTI counterparts... So, in order to "combine" these 2 pieces of information from the course, we need to find a way to recognize which course "section" student correspond to the LTI course student that we retrieved via LTI Advantage, and the email seems to be the only element we can use atm.
LTI remains the main and first level of communication for our tool (while we add additional intelligence to it when interfacing with a Canvas LMS, like identifying course sections and their members) so we end up querying both ways.
using endpoints like /api/v1/users/:user_id/profile
is definitely out of question: most often I'm fetching 100+ students from the course sections API call; I cannot issue 100+ GET requests just to get each student's email, that would be massively inefficient.
If you have suggestions on how to bridge this gap between the two worlds (Canvas and LTI) so we can more easily do our matching without resorting to email addresses I'd be more than happy to hear.
Our strategy, at the moment, is still sound though: When we import/sync the course learners into our tool we query LTI Advantage first (this allows us to "create" user accounts on our system that correspond to the LTI course students); This is followed by a call to Canvas REST API; as we do so we match the Canvas students with their corresponding LTI counterparts and we store the Canvas student "id" (as returned by the Canvas REST API) in the account we created (from the original LTI response), so the next time we need to sync with the LMS (useful in case more students have been added to the LMS course) we can match the results of the Canvas REST API call directly by Canvas user Id without relying on the student email; this ensure we're safe in the eventuality of a student updating the email address.
Moreover, @agschmid below provided a fantastic tip! it seems that `include[]=email` actually provides us with the email of the students! This parameter is not documented in the Canvas REST API documentation; is it safe to use? or is it something that might be removed with no notice at some point in time?