0% found this document useful (0 votes)
9 views3 pages

LMS API Integration and User Management

Uploaded by

Sanjay Vyas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

LMS API Integration and User Management

Uploaded by

Sanjay Vyas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LMS API Integration Guide

WSToken (Authentication Key)


Token: 39ccb3c60a1a454aabcee327cde00d40

Postman API Testing Guide


1■■ Test: Check if User Exists
GET [Link]
Params:
wstoken = 39ccb3c60a1a454aabcee327cde00d40
wsfunction = core_user_get_users_by_field
moodlewsrestformat = json
field = email
values[0] = student@[Link]

2■■ Test: Create User (ONLY if user does not exist)


POST [Link]
en=TOKEN&wsfunction;=core_user_create_users&moodlewsrestformat;=json
Form-data:
users[0][email] = student@[Link]
users[0][username] = student@[Link]
users[0][firstname] = John
users[0][lastname] = Doe
users[0][idnumber] = PRN123
users[0][auth] = manual
users[0][password] = Pass@12345

3■■ Test: Generate SSO Login URL


GET [Link]
Params:
wstoken = 39ccb3c60a1a454aabcee327cde00d40
wsfunction = auth_userkey_request_login_url
moodlewsrestformat = json
user[email] = student@[Link]

Response will contain loginurl. Redirect the student to this URL.

Developer Integration Workflow


1■■ Your portal receives a student login event.

2■■ Call API #1 (Check user exists):


• If user exists → Skip to Step 4.
• If user does NOT exist → Continue to Step 3.

3■■ Call API #2 (Create user in Moodle):


• Use student email, name, PRN, and temporary password.

4■■ Call API #3 (Generate one■click login link):


• Pass student email as: user[email] = student@[Link]
• Moodle returns one-time SSO login URL.

5■■ Redirect student to the returned login URL → They are logged in automatically.
End of Document

Common questions

Powered by AI

The LMS API integration first calls API #1 to check if the user exists by sending a GET request with the relevant email parameter. If the user exists, the integration proceeds directly to generating an SSO login URL (skipping to Step 4). If the user does not exist, it proceeds to Step 3, which involves calling API #2 to create a new user in Moodle using the provided email, name, and temporary password .

To check if a user exists, the API requires parameters such as wstoken, wsfunction set to core_user_get_users_by_field, moodlewsrestformat set to json, field set as email, and the specific values containing the email address to check. This operation is typically conducted via a GET request to a specified endpoint .

The integration guide ensures compatibility by using standard API calls and parameters that are broadly supported across Moodle versions. However, challenges can arise if specific functions or parameters are deprecated or modified in future Moodle updates, requiring constant review and potential updates to the integration process to maintain compatibility and prevent potential disruptions .

Once a user is created or their existence is verified, API #3 is invoked to generate a one-time SSO login URL by passing the user's email. This URL is returned by Moodle for redirecting the user. By using this URL, the system ensures that the user is logged in automatically, streamlining the access process .

Using a temporary password during user creation allows for immediate account setup without requiring user input at creation time, enabling automation. However, it poses security risks if not properly managed, such as exposure or misuse. Implementing measures like enforcing password changes on first login can mitigate these risks, ensuring that long-term security is maintained .

Redirecting students to the login URL obtained from the API is crucial for enabling Single Sign-On (SSO) access. This process ensures that students can be authenticated seamlessly without the need to re-enter their credentials, thereby simplifying the login process and enhancing user experience by providing direct access .

The 'wstoken' parameter acts as an authentication key required to access the API. It ensures that the requests being made to the server are authorized and originate from a verified source, preventing unauthorized access to the API functionalities .

The 'wsfunction' parameter specifies the particular function or operation to be executed by the API. This parameter guides the server on which specific action to perform, such as checking if a user exists or creating a new user, dictating the overall behavior and functionality of the API request .

Integrity and confidentiality are maintained by using an authentication token (wstoken) to control access to the API. This prevents unauthorized access and ensures that only verified requests can execute API functions. Additionally, HTTPS endpoints are used to encrypt the data in transit, protecting against eavesdropping and tampering .

If a user does not exist, the steps involve calling API #2 with a POST request. Required form-data parameters include: users' email, username, first name, last name, idnumber, authentication type (manual), and a password. These details are used to create the user in Moodle .

You might also like