Khan / khan-api

Documentation for (and examples of) using the Khan Academy API
http://www.khanacademy.org
377 stars 75 forks source link

401 When requesting information or exercises about a student #97

Closed jesseditson closed 8 years ago

jesseditson commented 8 years ago

Hey there!

I'm working with a flow where I'm interested in seeing the exercises of a student via the API. Right now, I'm able to successfully list students using the /api/v1/students api. I'm attempting to use a kaid value from a returned student to then request the /api/v1/user and/or /api/v1/exercises endpoints by passing a kaid GET parameter to the endpoint.

However, I'm getting a 401 when trying to request a kaid that belongs to a student. In the API explorer, the response is just empty, and when requesting via the API I get a 401 with the response text of Unauthorized.

Am I understanding the API correctly? My assumption is that I should be able to look at the exercises of a user that is in one of my classes.

What I'm ultimately after is that I'd like to get mastery data per topic/exercise (like the skill progress view under https://www.khanacademy.org/coach/reports/exercises), per student, via the API. Is this possible?

jesseditson commented 8 years ago

Ah, testing more and it looks like the original question was related to passing the query params in the URL via superagent - looks like that's not supported. I'll continue testing on my own to see if I can figure out the latter question.

alangpierce commented 8 years ago

Ok. Ideally every endpoint that allows you to specify a user should make it possible to specify that user by kaid, so it would be good to hear if you find endpoints that accept other user identifiers but not kaid.

Also, one thing to keep in mind is that for coach-related use cases, there's an access control nuance where you can only access student data when logged in as yourself, the developer (in other words, if the logged-in KA account matches the KA account that registered the API key). If a different coach logs into your app, then your app can load KA information on the coach, but not information on the students of the coach. The only real way to get that use case to work is to have the students themselves log into your app (since it's always possible to access the information of the logged-in user).

jesseditson commented 8 years ago

Ah, that's very helpful info. I did notice that the /students endpoint is missing from the API explorer (except it's mentioned in the /user endpoint where I found it), and that the API explorer doesn't accept a kaid param in the UI - however, in my own testing those seemed to work fine, so outside of missing documentation it's working as expected so far - I'll report back if I find other inconsistencies!