Backported auth changes (daa205e428ba0022a0b6a6a89c11f61bb8cb0984)

Fix auth problems (after coursera changes) in mechanize branch too