doc/api/provisioning.md
Many external tools will need to know which users are enrolled in a course and their roles. The approaches to this are varied depending on the version of LTI used and sometimes a single approach is not sufficient for all the use cases a tool might be interested in. Here, we outline several different approaches:
The IMS <a href="https://www.imsglobal.org/spec/lti-nrps/v2p0" target="_blank"> Names and Role Provisioning Service (NRPS)</a> provides an efficient API for synchronizing course rosters. This capability is only available to LTI 1.3 tools. We will not discuss details of the specification here, but instead focus on configuring and using NRPS within the Canvas platform.
Before NRPS can be used, an <a href="https://community.canvaslms.com/t5/Admin-Guide/How-do-I-configure-an-LTI-key-for-an-account/ta-p/140" target="_blank">LTI Developer Key must be created</a> and enabled with the https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly scope. Next, the <a href="https://community.canvaslms.com/t5/Admin-Guide/How-do-I-configure-an-external-app-for-an-account-using-a-client/ta-p/202" target="_blank"> external tool must be installed</a> in, or above, the context of the course that needs to be provisioned.
As with the other LTI Advantage service, tools must complete a specific <a href="file.oauth.html#accessing-lti-advantage-services" target="_blank">OAuth2 client credentials</a> grant in order to obtain an access token. This access token works for any course that the tool is available in. A single token can be used for multiple courses and services.
Once an access token is obtained, tools may begin to <a href="names_and_role.html" target="_blank">synchronize data using NRPS</a>. Using endpoint require knowledge of the context_memberships_url, which can either be obtained during the LTI launch in the <a href="https://www.imsglobal.org/spec/lti-nrps/v2p0#lti-1-3-integration" target="_blank">Names and Role Service claim</a>, or by substituting the desired course_id/group_id in the <a href="names_and_role.html" target="_blank">Names and Role API</a>.
Note: Once a single launch has happened from a course, the tool has enough information to use NRPS at any time and get info about all the users.
This approach requires an LTI integration (any version) to be configured and visible somewhere within a Canvas course. Ideally, this LTI connection will already have an LTI SSO mechanism. If username, login ID, email, and/or SIS ID is required, make sure the privacy level is set to Public in the tool configuration. Otherwise, Canvas will only send an opaque LTI user id (as the user_id parameter) and a Canvas ID (as the custom_canvas_user_id).
In the event that the LTI standard alone is not enough to satisfy your tool's provisioning needs, Canvas has an open REST API and a data service (<a href="https://community.canvaslms.com/t5/Admin-Guide/What-is-Canvas-Data-Services/ta-p/142" target="_blank"> Canvas Data</a>). Using the API or Canvas Data can help overcome some of the limitations of LTI-only integrations, but they have their own challenges. Where possible, tools should try to avoid using services that are not part of the LTI standards unless it is absolutely necessary.
Accessing Canvas API's requires an institution to issue a <a href="file.developer_keys.html" target="_blank">Developer Key</a>. Once issued, tools can begin using <a href="file.oauth.html#accessing-canvas-api" target="_blank">OAuth2</a> to request access tokens from individual users. The access token issued to access LTI advantage services will not work to access REST APIs.
Accessing Canvas Data also has its own authentication system that is <a href="https://community.canvaslms.com/t5/Admin-Guide/What-is-Canvas-Data-Services/ta-p/142" target="_blank">discussed elsewhere</a>.
Other options include connecting directly to that same SIS that the client may be using, or leveraging <a href="https://community.canvaslms.com/t5/Admin-Guide/What-is-Canvas-Data-Services/ta-p/142" target="_blank"> Canvas Data</a> to pull flat files for courses and enrollments.