Hello Team,
I am working on a custom integration in OpenedX and need some guidance regarding authentication between an XBlock(CMS) and LMS APIs.
What I have implemented
-
I created a custom Django app inside the LMS.
-
Exposed APIs from this app.
-
Added authentication and permissions as below:
authentication_classes = [JwtAuthentication, SessionAuthentication]
permission_classes = [IsAuthenticated]
- These APIs are working perfectly when tested directly (via Postman or browser with proper authentication).
Current Issue
I have also created a custom XBlock. From the XBlock, I have .py a file, and I am trying to call these LMS APIs.
However, when I make the API call from the XBlock:
-
The request is treated as unauthorized
-
The user is detected as AnonymousUser
-
Authentication fails
What I need help with
-
How can I properly call LMS APIs from an XBlock Python file from CMS?
-
How can I pass the authenticated user/session from the XBlock to the LMS API?
-
Is there a recommended way to handle authentication (JWT/session) when calling internal LMS APIs from XBlocks?
-
Should I be using any specific Open edX utilities (like OAuth, JWT generation, or service user tokens) for this use case?
Any guidance, best practices, or examples would be really helpful.
Thanks in advance!