You can use ClientLogin to run in the background, but it is replaced (slowly) and does not work with all Google accounts (two-step), so I suggest you stick with oAuth2, it definitely works.
As I do this, open the WebBrowser , making sure IsScriptEnabled="true" then point it to
https://accounts.google.com/o/oauth2/auth?client_id=xxx&redirect_uri=https://www.mydomain.com/oauth2callback&scope=xxx&response_type=code
The important part is the redirect URL. Then you hook up the Navigating method for your WebBrowser to intercept the redirect to this URL.
<phone:WebBrowser Name="webbrowser" Navigating="webbrowser_Navigating" IsScriptEnabled="true" /> private void webbrowser_Navigating(object sender, NavigatingEventArgs e) { if (e.Uri.Host.Equals("www.mydomain.com")) { e.Cancel = true; HandleOAuthResponse(e.Uri.Query); } }
This will return you Google redirect redirects using code=xxx , which will then follow the rest of the documents and exchange them for a token that will last 30 minutes and an update token to activate authentication.
source share