If you are not redirected automatically, follow this link to example. ArcGIS REST JS Browser OAuth2