About the project
I’m am building an online dashboard for my students that shows their up-to-the-minute Khan Academy progress. This will require access to the Khan Academy API. I’d like to build the whole thing in Mathematica.
Last school year I downloaded 13 unique spreadsheets and built some kludgy [Visual Basic][2] to bring it all together. This year, I'd like to make use of Khan's API and automate it all. Here’s an example report: Dropbox - khanReport.xlsx
What’s working:
I can make unauthenticated calls with success:
badges = Dataset[URLExecute["http://www.khanacademy.org/api/v1/badges”]]
I followed this Create A Random Nonce String Using JavaScript and made
choices = {“A”, “B”, “C”, “D”, "E", "F", "G", "H", "I", "J", "K", "L",
"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y",
"Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
"m", "n", "o", "p", "q", "r", "t", "s", "u", "v", "w", "x", "y",
"z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
MakeNONCE[vals0_, bits0_] :=
Module[{vals = vals0, bits = bits0, result = ""},
For[i = 0, i < bits - 1, i++,
result = StringJoin[result, ToString[RandomChoice[vals]]]];
result
]
MakeNONCE[choices, 64]
I’ve written this, which I believe is formatted correctly but I still cannot generate a few values:
params = {"oauth_consumer_key" -> "7cPJxRmA5ybuaNQz",
"oauth_nonce" -> MakeNONCE[choices, 64], "oauth_version" -> "1.0",
"oauth_signature" -> "abc",
"oauth_signature_method" -> "HMAC-SHA1",
"oauth_timestamp" -> UnixTime[]};
URLExecute["https://www.khanacademy.org/api/auth2/request_token", \
params]
What I still need help with:
- I cannot generate the signature correctly. I know that
Hash[stuff,”SHA”]
is close, but I’m uncertain what stuff needs to be included in the hash. - Does my nonce code look right? Does it make sense? I’m certain there are built-in functions that would make this easy, but I couldn’t make them work.