Initial dump from http://developers.arcgis.com/en/javascript/jssamples/portal_oauth_inline.html