Accessing the `student_view_url` via API authentication or alternatives?

23 views
Skip to first unread message

neil.s...@dootrix.com

unread,
Aug 24, 2017, 10:13:14 AM8/24/17
to General Open edX discussion
I’m working on a React Native application where all the Edx course information needs to be displayed offline. 

I’ve authenticated the app using oauth2 endpoint (`client_id=…&grant_type=password&username=us...@example.com&password=p455w0rd` to `{{root}}/oauth2/access_token/`) and can access the API endpoints to get the users enrolled courses (`{{root}}/api/enrollment/v1/enrollment`) and the blocks within those courses (`{{root}}/api/courses/v1/blocks/?course_id={{course_id_url_friendly}}&depth=all&nav_depth=3&return_type=list&username={{username}}`). What I’m struggling to get is the contents of the HTML blocks.

I see in the official app (when viewing requests via a proxy) that it will request the actual webpage of the course, presumably the `student_view_url`. 

Is this the only way to get that content or is there an API endpoint I can use to return the content?

If the only way is to request the rendered `student_view_url`, how do I access that page? The only way I can tell in the official app is it looks like it’s passing the cookies to authenticate with the `studen_view_url`, which it must get when it authorises the user via the oauth2 endpoint. The cookies I get don’t work though, which I’ve tested in Postman (if I use cookies that I got from browsing my Edx site in Chrome, they do work). This begs me the question, is my authentication correct as I don’t get any scope returned when the official app returns a scope filled in with `read write` and two others.

A sample of what my authentication returns:

{
   
"access_token": "a12345...",
   
"token_type": "Bearer",
   
"expires_in": 2591999,
   
"scope": ""
}

So to reiterate;
  1. Is there a way to request the HTML content via the API (so returned in a JSON request) rather than the `student_view_url`
  2. If not then how do I authenticate to access the `student_view_url`?

Thanks!  
Reply all
Reply to author
Forward
0 new messages