01:44
Hello there, thanks so much for the help! I'm new to OAuth and just getting beyond novice level with Wolfram Language. I'm not sure where to go from here...
02:51
@MattGreen Ah sorry went off to clean the house and didn't see this. Ping me by using @b3m2a1. With OAuth you'll get the token and token secret after a first call to the API auth page, after your user authenticates, generally.
OAuthSigning`Private`HMACSha1SignatureService[
"http://www.khanacademy.org/api/auth2/request_token",
"HMAC",
"POST",
"7cPJxRmA5ybuaNQz",
"superSecret",
"",
""
]
"http://www.khanacademy.org/api/auth2/request_token",
"HMAC",
"POST",
"7cPJxRmA5ybuaNQz",
"superSecret",
"",
""
]
Then you send them to the authorize endpoint (khanacademy.org/api/auth2/authorize) with the request_token and get back the oauth_token and oauth_token_secret. You generally need to have the user copy them in via prompt, although in the OAuth framework there seems to be some effort towards doing it via the ChannelFramework and I may implement something of my own for that.
Generally though I tend to write HTML pages that pull it the keys in Javascript and display them on the page, telling them to copy it into Mathematica (and giving them a prompt to)
Well the ServiceConnect framework provides the prompt, but the pages are my own. I'd suggest making a page and putting it in the cloud using
CloudExport
and passing that as your callback_url.
14 hours later…
1 hour later…
18:40
Thanks @b3m2a1. I'm attempting to do this (from: github.com/Khan/khan-api/wiki/Khan-Academy-API-Authentication)
Alternative: logging in directly with your own account
If you are logging in as yourself (that is, the KA user who registered the API key), then you have the option to skip the browser-based approval step and approve the token directly by making a POST request with your KA credentials. This makes it easier to log in automatically without manual steps.
To do this, send a POST request to https://www.khanacademy.org/api/auth2/authorize with the following parameters in the POST body:
oauth_token (required) - The request token.
If you are logging in as yourself (that is, the KA user who registered the API key), then you have the option to skip the browser-based approval step and approve the token directly by making a POST request with your KA credentials. This makes it easier to log in automatically without manual steps.
To do this, send a POST request to https://www.khanacademy.org/api/auth2/authorize with the following parameters in the POST body:
oauth_token (required) - The request token.
19:01
Yes @b3m2a1, I can get the request token and secret. I have been trying to send them to the auth URL but I'm having trouble putting the string together. I'm not sure how to specify the method as POST. I also don't understand the callback_url purpose. Can you link me something I could read to learn more?
"https://www.wolframcloud.com/objects/user-affd7b1c-ecb6-4ccc-8cc4-4d107e2bf04a/o/oauthflow/oauth2callback-request_token-request_token _secret"
"https://www.wolframcloud.com/objects/b3m2a1/o/oauthflow/\ oauth2callback-request_token-request_token_secret" // SystemOpen
That's a callback_url you can pass and the person will be routed there. It finds the parameters in the query string and inserts them into the page.
"https://www.wolframcloud.com/objects/user-affd7b1c-ecb6-4ccc-8cc4-\ 4d107e2bf04a/o/oauthflow/oauth2callback-access_token"
OAuthDialogDump`Private`MultipleKeyDialog[ "Khan Academy", { "Access Token" -> "access_token" }, URLBuild@ <| "Scheme" -> "http", "Domain" -> "www.khanacademy.org", "Path" -> {"", "api", "auth2", "authorize"}, "Query" -> { "oauth_token" -> $oauthtoken, "oauth_callback" -> oauthcallbackurl } |>, None ]
And `oauthcalbackurl` is optional, but you can try `"https://www.wolframcloud.com/objects/user-affd7b1c-ecb6-4ccc-8cc4-\
4d107e2bf04a/o/oauthflow/oauth2callback-access_token"`
4d107e2bf04a/o/oauthflow/oauth2callback-access_token"`
19:33
OAuthDialogDump`Private`MultipleKeyDialog["Khan Academy", {"OAuth \
Verifier" -> "oauth_verifier"},
URLBuild@<|"Scheme" -> "http", "Domain" -> "www.khanacademy.org",
"Path" -> {"", "api", "auth2", "authorize"},
"Query" -> {"oauth_token" -> requestToken[[4]],
"oauth_callback" ->
"https://www.wolframcloud.com/objects/user-affd7b1c-ecb6-4ccc-\
8cc4-4d107e2bf04a/o/oauthflow/oauth2callback-access_token"}|>, None]
Verifier" -> "oauth_verifier"},
URLBuild@<|"Scheme" -> "http", "Domain" -> "www.khanacademy.org",
"Path" -> {"", "api", "auth2", "authorize"},
"Query" -> {"oauth_token" -> requestToken[[4]],
"oauth_callback" ->
"https://www.wolframcloud.com/objects/user-affd7b1c-ecb6-4ccc-\
8cc4-4d107e2bf04a/o/oauthflow/oauth2callback-access_token"}|>, None]
next day → last day (21 days later) »