Articles in this section

How to Embed a LiveClass Session in Moodle

Published:

Embed a specific LiveClass session directly into Moodle so learners can join without leaving their course. This requires a server-side Moodle activity or local plugin to securely request a fresh embed URL for each page load.

Who this is for: Moodle administrators and developers

Before You Begin

Make sure you have completed the following:

  1. Create a LiveClass session. Note its session ID. You do not need to retrieve or store the attendee invite token.

  2. Allow your Moodle site. In LiveClass, go to Integrations → Embed → Allowed sites and add your Moodle origin, such as https://learn.example.edu. Include the scheme and hostname, but not a path. Each subdomain is a separate origin.

  3. Generate an Embed API key. Go to Integrations → Embed and generate a key. Store it in your server-side Moodle/plugin configuration or secret manager. You can rotate or revoke it from the same page.

  4. Test the embed. Under Integrations → Embed → Quick test, select the session and allowed origin. Use the temporary iframe snippet to check the browser behavior.

Important: The Embed API key is separate from the general LiveClass API keys under Integrations → API keys. It works only with the embed-launch endpoint and creates attendee access. Never expose it in Moodle page content, browser-side JavaScript, source control, or logs.

Step 1: Configure the Moodle Activity

Configure your Moodle activity or plugin with the relevant LiveClass session ID. Store the ID in private activity settings or maintain a server-side mapping between Moodle activities and LiveClass sessions.

A static Moodle Page or URL resource cannot safely store an expiring embed URL.

📸 Screenshot: Moodle activity settings with the LiveClass session ID field.

Step 2: Request an Embed URL

When Moodle renders the activity, its server must request a fresh embed URL from LiveClass.

Send a POST request to the following endpoint:

POST https://api.liveclass.io/v1/integrations/embed-launch
Authorization: Bearer <LIVECLASS_EMBED_API_KEY>
Content-Type: application/json

{
  "sessionId": "<LIVECLASS_SESSION_ID>",
  "embedOrigin": "https://learn.example.edu"
}

Keep the API key in server-side configuration. Check that the request succeeds before using the returned embedPath.

Build the iframe URL using https://app.liveclass.io as the base URL and the returned path.

📸 Screenshot: LiveClass Embed settings showing the API key and allowed Moodle origin.

Step 3: Add the Session to an Iframe

Render the returned URL in an iframe on the Moodle activity page.

Use the following iframe configuration:

<iframe
  src="FRESH_URL_RETURNED_BY_LIVECLASS"
  title="LiveClass session"
  allow="camera; microphone; display-capture; autoplay; fullscreen; clipboard-write"
  referrerpolicy="no-referrer"
  style="width:100%;min-height:640px;border:0"
></iframe>

Replace FRESH_URL_RETURNED_BY_LIVECLASS with the URL generated by your server. Do not construct the URL manually.

Important security requirements:

  • Embed URLs expire after 10 minutes. Generate a fresh URL each time the activity page is rendered.

  • Exclude the rendered activity from page and CDN caching to prevent expired URLs from being reused.

  • Never store the embed URL in Moodle content or course backups.

  • Do not put an attendee invite token in the browser or iframe URL.

  • Use HTTPS for camera and microphone access.

📸 Screenshot: A LiveClass session displayed inside a Moodle activity.

Step 4: Map Moodle Activities to LiveClass Sessions

Choose the mapping method that fits your setup:

  • One session: Store the session ID in the activity's private settings.

  • Multiple sessions: Create a separate Moodle activity for each LiveClass session, or maintain a server-side mapping for each activity.

Each activity opens only the LiveClass session associated with its configured session ID. The embed does not provide a session catalog.

Step 5: Test the Embed

  1. Sign in as an enrolled learner and open the Moodle activity from the configured HTTPS origin.

  2. Allow camera and microphone access in the browser.

  3. Confirm the iframe includes the required permissions, including display-capture if learners need to share their screens.

  4. Check that the activity is not serving a cached, expired embed URL.

  5. Test from an unregistered origin. The browser should refuse to frame the session.

  6. Verify the session inside the Moodle page. Opening the embed URL in a separate browser tab does not test the frame-ancestors policy.

📸 Screenshot: A learner viewing the embedded LiveClass session in Moodle.

Troubleshooting

IssueWhat to check
Embed URL has expiredGenerate a fresh URL on the server and disable page/CDN caching for the rendered activity.
Embedding is not configuredConfirm the exact Moodle origin is registered under Integrations → Embed → Allowed sites.
Camera or microphone does not workUse HTTPS and check browser permissions and iframe settings.
Session cannot load or returns a 504 errorContact LiveClass support to check the /embed* API/CDN route. Moodle cannot add the required response security header itself.
Embed works in a tab but not inside MoodleTest it within the Moodle page and verify the configured origin and framing policy.

Alternative Without a Moodle Plugin

If you cannot develop a Moodle plugin, share the attendee join link through a restricted Moodle activity instead. Limit access to the intended learners, and do not paste an expiring iframe URL into Moodle content.

Conclusion

Embedding LiveClass in Moodle requires an approved Moodle origin, a server-side Embed API key, and a fresh URL for each activity page render. Configure session mappings carefully, disable caching for rendered embed URLs, and test access as an enrolled learner to provide a secure joining experience.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied