public void signOut() { if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); } } }
@Override protected String doInBackground(Void... params) { String token = null; try { String scope = String.format("oauth2:%s", Scopes.PROFILE); token = GoogleAuthUtil.getToken(LoginActivity.this, Plus.AccountApi.getAccountName(mGoogleApiClient), scope); } catch (IOException transientEx) { /* Network or server error */ Log.e(TAG, "Error authenticating with Google: " + transientEx); errorMessage = mStringNetworkError + transientEx.getMessage(); showAlertDialog(errorMessage); } catch (UserRecoverableAuthException e) { /* We probably need to ask for permissions, so start the intent if there is none pending */ Log.w(TAG, "Recoverable Google OAuth error: " + e.toString()); if (!mGoogleIntentInProgress) { mGoogleIntentInProgress = true; Intent recover = e.getIntent(); 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.getMessage(), authEx); errorMessage = mStringAuthError + authEx.getMessage(); showAlertDialog(errorMessage); } return token; }
login(); } else if (mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient); mGoogleApiClient.disconnect(); mGoogleApiClient.connect();
public void signOut() { if (mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); mGoogleApiClient.connect(); } }
@Override public void onConnected(Bundle bundle) { if (mGridView.getAdapter() != null) { ((UploadedVideoAdapter) mGridView.getAdapter()).notifyDataSetChanged(); } setProfileInfo(); mCallbacks.onConnected(Plus.AccountApi.getAccountName(mGoogleApiClient)); }
/** Sign out and disconnect from the APIs. */ public void signOut() { if (!mGoogleApiClient.isConnected()) { // nothing to do debugLog("signOut: was already disconnected, ignoring."); return; } // for Plus, "signing out" means clearing the default account and // then disconnecting if (0 != (mRequestedClients & CLIENT_PLUS)) { debugLog("Clearing default account on PlusClient."); Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); } // For the games client, signing out means calling signOut and // disconnecting if (0 != (mRequestedClients & CLIENT_GAMES)) { debugLog("Signing out from the Google API Client."); Games.signOut(mGoogleApiClient); } // Ready to disconnect debugLog("Disconnecting client."); mConnectOnStart = false; mConnecting = false; mGoogleApiClient.disconnect(); }
/** Sign out and disconnect from the APIs. */ public void signOut() { if (!mGoogleApiClient.isConnected()) { // nothing to do debugLog("signOut: was already disconnected, ignoring."); return; } // for Plus, "signing out" means clearing the default account and // then disconnecting if (0 != (mRequestedClients & CLIENT_PLUS)) { debugLog("Clearing default account on PlusClient."); Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); } // For the games client, signing out means calling signOut and // disconnecting if (0 != (mRequestedClients & CLIENT_GAMES)) { debugLog("Signing out from the Google API Client."); Games.signOut(mGoogleApiClient); } // Ready to disconnect debugLog("Disconnecting client."); mConnectOnStart = false; mConnecting = false; mGoogleApiClient.disconnect(); }