protected internal override string doInBackground(params Void[] @params) { string token = null; try { string scope = string.Format("oauth2:{0}", Scopes.PLUS_LOGIN); token = GoogleAuthUtil.getToken(outerInstance, Plus.AccountApi.getAccountName(outerInstance.mGoogleApiClient), scope); } catch (IOException transientEx) { /* Network or server error */ Log.e(TAG, "Error authenticating with Google: " + transientEx); errorMessage = "Network error: " + transientEx.Message; } catch (UserRecoverableAuthException e) { Log.w(TAG, "Recoverable Google OAuth error: " + e.ToString()); /* We probably need to ask for permissions, so start the intent if there is none pending */ if (!outerInstance.mGoogleIntentInProgress) { outerInstance.mGoogleIntentInProgress = true; Intent recover = e.Intent; startActivityForResult(recover, RC_GOOGLE_LOGIN); } } catch (GoogleAuthException authEx) { /* The call is not ever expected to succeed assuming you have already verified that * Google Play services is installed. */ Log.e(TAG, "Error authenticating with Google: " + authEx.Message, authEx); errorMessage = "Error authenticating with Google: " + authEx.Message; } return(token); }