xamarin/Xamarin.Auth — pull request #20 by gaearon (2013-05-24 19:15:40+00:00)
Title: Implement browser authentication for WebAuthenticator

We couldn't use Xamarin.Auth as is because we needed to support authentication via browser instead of presenting modal view controller. The reason is, we noticed a lot of people are already logged into Twitter/Facebook in Safari but don't remember / care to enter their passwords when presented with a modal form.

This pull requests adds `void AuthenticateWithBrowser (IExternalUrlManager)` to `WebAuthenticator` as an alternative to presenting a view controller.

`IExternalUrlManager` as a platform-agnostic way to open an external URL in browser and wait for a callback. I'm not sure how it can be implemented in Android, but an iOS implementation is shown in `HandleOpenUrlManager`.

A drawback of this approach is that you need to call its `HandleOpenUrl` and `WillEnterForeground` in `AppDelegate` for it to work, but I find this reasonable and I don't see an easy workaround.

Unfortunately I didn't start this in a branch, so there is an unrelated change in this pull request: adding support for JSON auth_token callbacks in `OAuth2Authenticator`. These are required for supporting Google login. I wanted as little dependencies as possible so I used `System.Json`—is this okay? I didn't want to write another parser..

If you want me to split them, I will, but in a few days. The change is small though.

Finally, Miguel asked me to send patches as MIT/X11, but I'm not sure how this should be done. Should we annotate commits? Add license headers to new files? Modify existing headers by adding another license? I'm confused.

Thanks for considering this!