Open ChemGuy88 opened 5 years ago
I'm no expert on this code, or flask, but I believe the error means that you have to run this code actually as part of a flask request -- you can't just call the functions via the CLI. So you'll need to write a program that uses this in its flask route, and then visit the appropriate url in your browser (or maybe use curl
).
@csilvers is right in that you should be using this as part of a flask request. It is not designed to be used via the CLI.
Your first line kapi = KhanAPI(CONSUMER_KEY,CONSUMER_SECRET)
is not correct because the arguments must be the token
and secret
returned from the oauth process, not the CONSUMER_KEY
and CONSUMER_SECRET
. The token
and secret
are retrieved by completing the oath process in the browser.
This example bootstraps getting the token
and secret
via a Flask application, and is useful if you are trying to create a UI via the web for people to consume their Khan Academy data. In that case, you can start the server via the CLI by going to the example root and entering
python server.py
Assuming you have installed required dependencies (Flask and rauth), that will run a server that can be accessed at http://localhost:5000
on your development machine, which will allow you to interact with the API via a webpage.
If you just want to use a command line to access your own students' data, you could look at my package at khan_api_wrapper.
I used the Flask example in this repo, only editing the values
CONSUMER_KEY
andCONSUMER_SECRET
on lines 14 and 15 ofkhan_api.py
, respectively. I then run:where
abc123
is my actual consumer key.I tried troubleshooting it, and got the following three results:
I read the docstring for
KhanAcademySignIn
and the comment block that follows it, but I don't understand it. Do I need to flesh out the example more, or is there some server-side issue going on?Thanks for teaching the kids,