mozilla-b2g/gaia — pull request #24407 by jrburke (2014-09-24 23:56:22+00:00)
Title: Bug 1069412 - Email constantly asks me to reauthenticate

Includes the GELAM changes from https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/341. The gaia change is:

Move to a mozbrowser iframe for the oauth google user flow instead of window.open.

This means the window polling for its close can be removed from `cards/oauth2/fetch`, and now a card, `setup_oauth2`, is used instead. That card creates the mozbrowser iframe, and communicates back to the fetch module via an onBrowseComplete callback passed as an args property during card construction.

No new strings are needed for this change. `setup_oauth2` shows the URL for the mozbrowser in its header, and uses the standard back arrow to cancel the card.

When `setup_oauth2` is destroyed, it asks for appSelf and calls the `clearBrowserData` API. This pathway is called both on a cancel of the `setup_oauth2` or successful completion of the oauth jump.

The "http://localhost" as the redirect_uri was kept because the "redirects" mechanism in the manifest still works with this approach, and I personally prefer reading query string arguments vs polling for a title change if "urn:ietf:wg:oauth:2.0:oob:auto" was used instead. Feels more API-like. It also meant no new changes from what is already working and configured for the oauth profile on google.

I removed one of the "redirects" entries, since we do not use it, and to make it clearer what is actually used. For the redirect.html, it now no longer needs the redirect.js script to do a postMessage call, so it was removed.

The feedback for the user with a mozbrowser is not as nice as window.open. window.open had a progress candy bar and would show a lock icon for https sites. However, the data indicator in the status bar gives a hint that "data things are happening" and the URL that is shown shows the protocol. This sort of display also matches what Calendar does, so there is precedent for it.