Migrating LMS APIs to DRF
This document Big changes to edx-platform contains a segment to convert
Improve HTTP APIs.
- Switch all APIs to be using DRF with standard Auth classes.
- Document APIs to clearly separate Operator, Instructor, and Learner APIs.
- Map existing APIs to product features and build out missing APIs.
- Define best practices for how to build APIs?
### Tasks releated with 1st point Switch all APIs to be using DRF with standard Auth classes.
- [x] https://github.com/openedx/edx-platform/issues/35058
- [x] https://github.com/openedx/edx-platform/issues/35059
- [x] https://github.com/openedx/edx-platform/issues/35060
- [x] https://github.com/openedx/edx-platform/issues/35061
- [x] https://github.com/openedx/edx-platform/issues/35062
- [ ] https://github.com/openedx/edx-platform/issues/35064
- [ ] https://github.com/openedx/edx-platform/issues/35065
- [ ] https://github.com/openedx/edx-platform/issues/35066
- [ ] https://github.com/openedx/edx-platform/issues/35067
- [ ] https://github.com/openedx/edx-platform/issues/35068
- [ ] https://github.com/openedx/edx-platform/issues/35069
- [ ] https://github.com/openedx/edx-platform/issues/35070
- [ ] https://github.com/openedx/edx-platform/issues/35071
- [ ] https://github.com/openedx/edx-platform/issues/35072
- [ ] https://github.com/openedx/edx-platform/issues/35073
- [ ] https://github.com/openedx/edx-platform/issues/35074
- [ ] https://github.com/openedx/edx-platform/issues/35075
- [ ] https://github.com/openedx/edx-platform/issues/35283
- [ ] https://github.com/openedx/edx-platform/issues/35112
- [x] https://github.com/openedx/edx-platform/issues/35114
- [ ] https://github.com/openedx/edx-platform/issues/35232
- [x] https://github.com/openedx/edx-platform/issues/35347
- [x] https://github.com/openedx/edx-platform/issues/35351
- [x] https://github.com/openedx/edx-platform/issues/35352
- [x] https://github.com/openedx/edx-platform/issues/35353
- [x] https://github.com/openedx/edx-platform/issues/35355
- [x] https://github.com/openedx/edx-platform/issues/35356
- [x] https://github.com/openedx/edx-platform/issues/35357
- [x] https://github.com/openedx/edx-platform/issues/35344
- [x] https://github.com/openedx/edx-platform/issues/35346
- [x] https://github.com/openedx/edx-platform/issues/35339
- [x] https://github.com/openedx/edx-platform/issues/35354
- [x] https://github.com/openedx/edx-platform/issues/35358
- [x] https://github.com/openedx/edx-platform/issues/35359
- [x] https://github.com/openedx/edx-platform/issues/35284
- [x] https://github.com/openedx/edx-platform/issues/35360
- [x] https://github.com/openedx/edx-platform/issues/35361
- [x] https://github.com/openedx/edx-platform/issues/35362
- [x] https://github.com/openedx/edx-platform/issues/35363
- [x] https://github.com/openedx/edx-platform/issues/35364
- [x] https://github.com/openedx/edx-platform/issues/35365
- [x] https://github.com/openedx/edx-platform/issues/35085
- [x] https://github.com/openedx/edx-platform/issues/35262
- [x] https://github.com/openedx/edx-platform/issues/35285
- [ ] https://github.com/openedx/edx-platform/issues/35330
### Tasks
PRS List
- https://github.com/openedx/edx-platform/pull/35039
- https://github.com/openedx/edx-platform/pull/35105
- https://github.com/openedx/edx-platform/pull/35111
- https://github.com/openedx/edx-platform/pull/35135
- https://github.com/openedx/edx-platform/pull/35084
- https://github.com/openedx/edx-platform/pull/35260
- https://github.com/openedx/edx-platform/pull/35323
- https://github.com/openedx/edx-platform/pull/35174
- https://github.com/openedx/edx-platform/pull/35148
- https://github.com/openedx/edx-platform/pull/35332
- https://github.com/openedx/edx-platform/pull/35343
- https://github.com/openedx/edx-platform/pull/35345
- https://github.com/openedx/edx-platform/pull/35350
- https://github.com/openedx/edx-platform/pull/35366
- https://github.com/openedx/edx-platform/pull/35387
- https://github.com/openedx/edx-platform/pull/35392
- https://github.com/openedx/edx-platform/pull/35394
- https://github.com/openedx/edx-platform/pull/35395
- https://github.com/openedx/edx-platform/pull/35404
- https://github.com/openedx/edx-platform/pull/35463
- https://github.com/openedx/edx-platform/pull/35460
- https://github.com/openedx/edx-platform/pull/35464
- https://github.com/openedx/edx-platform/pull/35521
- https://github.com/openedx/edx-platform/pull/35534
- https://github.com/openedx/edx-platform/pull/35536
- https://github.com/openedx/edx-platform/pull/35577
- https://github.com/openedx/edx-platform/pull/35584
- https://github.com/openedx/edx-platform/pull/35594
- https://github.com/openedx/edx-platform/pull/35599
- https://github.com/openedx/edx-platform/pull/35604
Testing guide lines via postman
How to generate csrf http://local.edly.io:8000/csrf/api/v1/token It will return the csrf token which is required for some apis.
For login authentication
http://local.edly.io:8000/api/user/v2/account/login_session/
body-form-data
email_or_username = admin
password = edx
headers information
x-csrftoken: csrf fresh token
Generate access token via postman http://local.edly.io:8000/oauth2/access_token
You can curl command as well as follows. Just pass your token.
curl --location ‘http://local.edly.io:8000/courses/course-v1:edx+cs222+2311/instructor/api/get_student_progress_url’
–header ‘Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJvcGVuZWR4IiwiZXhwIjoxNzI0MjMzNDc2LCJncmFudF90eXBlIjoiY2xpZW50LWNyZWRlbnRpYWxzIiwiaWF0IjoxNzI0MjI5ODc2LCJpc3MiOiJodHRwOi8vbG9jYWwuZWRseS5pby9vYXV0aDIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiNlX3VzZXIiLCJzY29wZXMiOlsicmVhZCIsIndyaXRlIiwiZW1haWwiLCJwcm9maWxlIl0sInZlcnNpb24iOiIxLjIuMCIsInN1YiI6IjI2MjYyNDAxYzUyOGQ3YzRhNmJiZWFiZTA0NTVlYzQ2IiwiZmlsdGVycyI6W10sImlzX3Jlc3RyaWN0ZWQiOmZhbHNlLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZW1haWwiOiJsb2dpbl9zZXJ2aWNlX3VzZXJAZmFrZS5lbWFpbCIsIm5hbWUiOm51bGwsImZhbWlseV9uYW1lIjoiIiwiZ2l2ZW5fbmFtZSI6IiIsImFkbWluaXN0cmF0b3IiOmZhbHNlLCJzdXBlcnVzZXIiOmZhbHNlfQ.t1GjtoPntvTgY153qlkoUHZ2N43U-Ac5uJY5EUTEo0g’
-X POST --form ‘unique_student_identifier=“audot”’
Amazing list and job @awais786 ! thank you very much for this very relevant list ! Where can we find the postman workspace & collections ? Thanks. Amaury
@AmauryVanEspen you can find some help material from here
Please let me know if you have some questions.
@AmauryVanEspen You can use these open tickets.
Hi @awais786 trying to set up the Postman Collection, with the CSRF tricks, i still have an issue https://openedx.atlassian.net/wiki/spaces/AC/pages/3516268561/How+to+authenticate+and+query+edX+APIs+with+Postman returning : 405 Method Not Allowed
not sure about how to add the script : var xsrfCookie = postman.getResponseCookie("csrftoken"); postman.setEnvironmentVariable('csrftoken', xsrfCookie.value);
collection folder ? the post-request script of the POST ? Thanks. Amaury
Hi @awais786 trying to set up the Postman Collection, with the CSRF tricks, i still have an issue https://openedx.atlassian.net/wiki/spaces/AC/pages/3516268561/How+to+authenticate+and+query+edX+APIs+with+Postman returning : 405 Method Not Allowed
not sure about how to add the script : var xsrfCookie = postman.getResponseCookie("csrftoken"); postman.setEnvironmentVariable('csrftoken', xsrfCookie.value);
collection folder ? the post-request script of the POST ? Thanks. Amaury
Please try this. https://discuss.openedx.org/t/authenticate-with-oauth-token-to-access-api-endpoints-instructor-apis-d/13658
@AmauryVanEspen Please check the last post with postman collection
@AmauryVanEspen Please check the last post with postman collection
hi @awais786 thanks, which instance should i use ? prod ? or a simple EduNExt Trial ? or is there an instance available for migration LMS API to DRF available ? Thanks Regards Amaury
@AmauryVanEspen I am using local tutor instance for testing purpose.
@awais786 @feanil This looks close to being done. Is there remaining work or should we close it out?
@kdmccormick There are only few left to get merge.
Additional APIs
- [x] #37070
- [x] #37071
One last api is in progress.