Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Don't let all the code samples and howto's lead you astray. They are intended for more complicated cases.</p> <ul> <li>This is not oauth2 authorization, its oauth2 authentication</li> <li>You're not the client with the clientID and the secret. Codecademy is the client with the clientID and the secret. Your codecademybot account simply is the user.</li> </ul> <p>This means that you only need to automate what ordinary users do when logging into codecademy. Play that interaction that in the browser a couple times with a dev tool listening in (IE dev tool, FireBug, whatever) and look at the conversation of HTTP requests.</p> <p>This is what you wish to emulate.</p> <p>From what I can see, </p> <ul> <li>Conversation starts by sending a request to <a href="http://codecademy.com/auth/google_oauth2" rel="nofollow">http://codecademy.com/auth/google_oauth2</a>.</li> <li>The request gets forwarded to a https url at google</li> <li>If I've previously logged in at google, a couple cookies get sent along and I get authenticated. The request gets sent back to the codecademy redirect_url at <a href="http://www.codecademy.com/auth/google_oauth2/callback" rel="nofollow">http://www.codecademy.com/auth/google_oauth2/callback</a> with the oauth2 authentication code as a parameter.</li> <li>Supposedly codecademy and google chat, for this takes about three seconds.</li> <li>They agree that I'm me and two cookies (<code>remember_user_token</code> and <code>_session_id</code>) get set in my browser before I get forwarded to <a href="http://www.codecademy.com/" rel="nofollow">http://www.codecademy.com/</a></li> </ul> <p>That last bit, I think, is interesting. How about you manually log in using your browser, listen in on the conversation and copy these two cookies to your automated code. See if they suffice as authentication tokens and allow you to fetch the data from the website.</p> <p>If not, then I warmly recommend @CrisBee21 s answer. Let's hope pyCurl can emulate the browser well enough to do the conversation for you.</p> <p>One more thing, when I browse around the site, I see one REST api request, namely <a href="http://www.codecademy.com/api/v1/notifications/" rel="nofollow">http://www.codecademy.com/api/v1/notifications/</a><em>userid</em>/unread_count?authentication_token=<em>some token</em> </p> <p>Surfing to <a href="http://www.codecademy.com/api/v1/users/" rel="nofollow">http://www.codecademy.com/api/v1/users/</a><em>userid</em>/?authentication_token=<em>the token</em> gives me more info about myself</p> <p><a href="http://www.codecademy.com/api/v1/users/" rel="nofollow">http://www.codecademy.com/api/v1/users/</a><em>userid</em>/groups?authentication_token=<em>the token</em> gives me the groups I'm in.</p> <p>If you have more documentation about the codecademy REST api, you could try and take it from there. I couldn't find any documentation, am making this up as I go along.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload