edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

Migrating LMS APIs to DRF

Open awais786 opened this issue 1 year ago • 10 comments

This document Big changes to edx-platform contains a segment to convert

Improve HTTP APIs.

  1. Switch all APIs to be using DRF with standard Auth classes.
  2. Document APIs to clearly separate Operator, Instructor, and Learner APIs.
  3. Map existing APIs to product features and build out missing APIs.
  4. Define best practices for how to build APIs?

How to test Instructor 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

awais786 avatar Jul 02 '24 07:07 awais786

PRS List

  1. https://github.com/openedx/edx-platform/pull/35039
  2. https://github.com/openedx/edx-platform/pull/35105
  3. https://github.com/openedx/edx-platform/pull/35111
  4. https://github.com/openedx/edx-platform/pull/35135
  5. https://github.com/openedx/edx-platform/pull/35084
  6. https://github.com/openedx/edx-platform/pull/35260
  7. https://github.com/openedx/edx-platform/pull/35323
  8. https://github.com/openedx/edx-platform/pull/35174
  9. https://github.com/openedx/edx-platform/pull/35148
  10. https://github.com/openedx/edx-platform/pull/35332
  11. https://github.com/openedx/edx-platform/pull/35343
  12. https://github.com/openedx/edx-platform/pull/35345
  13. https://github.com/openedx/edx-platform/pull/35350
  14. https://github.com/openedx/edx-platform/pull/35366
  15. https://github.com/openedx/edx-platform/pull/35387
  16. https://github.com/openedx/edx-platform/pull/35392
  17. https://github.com/openedx/edx-platform/pull/35394
  18. https://github.com/openedx/edx-platform/pull/35395
  19. https://github.com/openedx/edx-platform/pull/35404
  20. https://github.com/openedx/edx-platform/pull/35463
  21. https://github.com/openedx/edx-platform/pull/35460
  22. https://github.com/openedx/edx-platform/pull/35464
  23. https://github.com/openedx/edx-platform/pull/35521
  24. https://github.com/openedx/edx-platform/pull/35534
  25. https://github.com/openedx/edx-platform/pull/35536
  26. https://github.com/openedx/edx-platform/pull/35577
  27. https://github.com/openedx/edx-platform/pull/35584
  28. https://github.com/openedx/edx-platform/pull/35594
  29. https://github.com/openedx/edx-platform/pull/35599
  30. https://github.com/openedx/edx-platform/pull/35604

awais786 avatar Jul 19 '24 10:07 awais786

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”’

awais786 avatar Aug 08 '24 10:08 awais786

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 avatar Aug 13 '24 06:08 AmauryVanEspen

@AmauryVanEspen you can find some help material from here

Please let me know if you have some questions.

awais786 avatar Aug 13 '24 08:08 awais786

@AmauryVanEspen You can use these open tickets.

awais786 avatar Aug 13 '24 08:08 awais786

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

AmauryVanEspen avatar Aug 13 '24 09:08 AmauryVanEspen

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

awais786 avatar Aug 19 '24 12:08 awais786

@AmauryVanEspen Please check the last post with postman collection

awais786 avatar Aug 22 '24 13:08 awais786

@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 avatar Aug 23 '24 07:08 AmauryVanEspen

@AmauryVanEspen I am using local tutor instance for testing purpose.

awais786 avatar Aug 29 '24 07:08 awais786

@awais786 @feanil This looks close to being done. Is there remaining work or should we close it out?

kdmccormick avatar Jul 24 '25 13:07 kdmccormick

@kdmccormick There are only few left to get merge.

awais786 avatar Jul 24 '25 13:07 awais786

Additional APIs

  • [x] #37070
  • [x] #37071

hunzlahmalik avatar Jul 25 '25 13:07 hunzlahmalik

One last api is in progress.

awais786 avatar Sep 04 '25 11:09 awais786