Java Code Examples for com.google.android.gms.auth.api.signin.GoogleSignInResult#isSuccess()
The following examples show how to use
com.google.android.gms.auth.api.signin.GoogleSignInResult#isSuccess() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Fido2DemoActivity.java From security-samples with Apache License 2.0 | 6 votes |
private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); Log.d(TAG, "sign in result: " + result.getStatus().toString()); if (result.isSuccess()) { GoogleSignInAccount acct = result.getSignInAccount(); saveAccountSignInStatus(); Log.d(TAG, "account email" + acct.getEmail()); Log.d(TAG, "account displayName" + acct.getDisplayName()); Log.d(TAG, "account id" + acct.getId()); Log.d(TAG, "account idToken" + acct.getIdToken()); Log.d(TAG, "account scopes" + acct.getGrantedScopes()); } else { clearAccountSignInStatus(); } updateUI(); }
Example 2
Source File: DriverHome.java From UberClone with MIT License | 6 votes |
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { account = result.getSignInAccount(); Common.userID=account.getId(); loadUser(); }else if(isLoggedInFacebook){ GraphRequest request = GraphRequest.newMeRequest( accessToken, new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { String id=object.optString("id"); Common.userID=id; loadUser(); } }); request.executeAsync(); }else{ Common.userID=FirebaseAuth.getInstance().getCurrentUser().getUid(); loadUser(); } }
Example 3
Source File: FireSignin.java From Learning-Resources with MIT License | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mCallbackManager.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUESTCODE_SIGN_IN_GOOGLE) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } else { mPrgrsbrMain.setVisibility(View.GONE); Snackbar.make(mCrdntrlyot, "Google authentication failed.", Snackbar.LENGTH_LONG).show(); } } }
Example 4
Source File: GoogleSignInActivity.java From endpoints-samples with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } else { // Google Sign In failed, update UI appropriately // [START_EXCLUDE] updateUI(null); // [END_EXCLUDE] } } }
Example 5
Source File: MainActivity.java From stitch-examples with Apache License 2.0 | 6 votes |
private void handleGooglSignInResult(final GoogleSignInResult result) { if (result == null) { Log.e(TAG, "Got a null GoogleSignInResult"); return; } Log.d(TAG, "handleGooglSignInResult:" + result.isSuccess()); if (result.isSuccess()) { final GoogleCredential googleCredential = new GoogleCredential(result.getSignInAccount().getServerAuthCode()); _client.getAuth().loginWithCredential(googleCredential).addOnCompleteListener(new OnCompleteListener<StitchUser>() { @Override public void onComplete(@NonNull final Task<StitchUser> task) { if (task.isSuccessful()) { initTodoView(); } else { Log.e(TAG, "Error logging in with Google", task.getException()); } } }); } else { Toast.makeText(MainActivity.this, "Failed to log on using Google. Result: " + result.getStatus(), Toast.LENGTH_LONG).show(); } }
Example 6
Source File: Home.java From UberClone with MIT License | 6 votes |
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { account = result.getSignInAccount(); Common.userID=account.getId(); loadUser(); }else if(isLoggedInFacebook){ GraphRequest request = GraphRequest.newMeRequest( accessToken, new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { String id=object.optString("id"); Common.userID=id; loadUser(); } }); request.executeAsync(); }else{ Common.userID=FirebaseAuth.getInstance().getCurrentUser().getUid(); loadUser(); } }
Example 7
Source File: Loginactivity.java From LuxVilla with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } else { linearLayout.setVisibility(View.VISIBLE); layoutprogressbar.setVisibility(View.GONE); Snackbar.make(linearLayout,"Ocorreu um erro ao conectar", Snackbar.LENGTH_LONG).show(); } } }
Example 8
Source File: SignInBaseActivity.java From Expert-Android-Programming with MIT License | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { // Google Sign In was successful, authenticate with FireBase GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } } else { callbackManager.onActivityResult(requestCode, resultCode, data); } }
Example 9
Source File: RxGoogleAuthFragment.java From RxSocialAuth with Apache License 2.0 | 6 votes |
/** * Handle google sign in result * * @param result the GoogleSignInResult result */ public void handleSignInResult(final GoogleSignInResult result) { if (result.isSuccess()) { GoogleSignInAccount account = result.getSignInAccount(); mGoogleApiClient.disconnect(); verifySmartLockIsEnabled(new RxAccount(account)); } else { // delete credential if(mCredential != null) { Auth.CredentialsApi.delete(mGoogleApiClient, mCredential).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { mGoogleApiClient.disconnect(); mAccountSubject.onError(new Throwable(result.getStatus().toString())); } }); } else { mGoogleApiClient.disconnect(); mAccountSubject.onError(new Throwable(result.getStatus().toString())); } } }
Example 10
Source File: LoadingActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (requestCode == GOOGLE_SIGN_IN_CODE) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result == null) return; if (result.isSuccess()) { googleSignedIn(result.getSignInAccount()); } else { if (result.getStatus().getStatusCode() == GoogleSignInStatusCodes.SIGN_IN_CANCELLED) Prefs.putBoolean(PK.SHOULD_PROMPT_GOOGLE_PLAY, false); String msg = result.getStatus().getStatusMessage(); if (msg != null && !msg.isEmpty()) Toaster.with(this).message(msg).show(); } } else { super.onActivityResult(requestCode, resultCode, data); } }
Example 11
Source File: PreferenceActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (requestCode == GOOGLE_SIGN_IN_CODE) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result == null) return; if (result.isSuccess()) { onBackPressed(); } else { String msg = result.getStatus().getStatusMessage(); if (msg != null && !msg.isEmpty()) showToast(Toaster.build().message(msg)); } } else { super.onActivityResult(requestCode, resultCode, data); } }
Example 12
Source File: GoogleLogin.java From Android-Smart-Login with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data, SmartLoginConfig config) { ProgressDialog progress = ProgressDialog.show(config.getActivity(), "", config.getActivity().getString(R.string.getting_data), true); GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); Log.d("GOOGLE SIGN IN", "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); SmartGoogleUser googleUser = UserUtil.populateGoogleUser(acct); // Save the user UserSessionManager.setUserSession(config.getActivity(), googleUser); config.getCallback().onLoginSuccess(googleUser); progress.dismiss(); } else { Log.d("GOOGLE SIGN IN", "" + requestCode); // Signed out, show unauthenticated UI. progress.dismiss(); config.getCallback().onLoginFailure(new SmartLoginException("Google login failed", LoginType.Google)); } }
Example 13
Source File: MainActivity.java From stitch-examples with Apache License 2.0 | 6 votes |
private void handleGooglSignInResult(final GoogleSignInResult result) { if (result == null) { Log.e(TAG, "Got a null GoogleSignInResult"); return; } Log.d(TAG, "handleGooglSignInResult:" + result.isSuccess()); if (result.isSuccess()) { final GoogleCredential googleCredential = new GoogleCredential(result.getSignInAccount().getServerAuthCode()); _client.getAuth().loginWithCredential(googleCredential).addOnCompleteListener(new OnCompleteListener<StitchUser>() { @Override public void onComplete(@NonNull final Task<StitchUser> task) { if (task.isSuccessful()) { initTodoView(); } else { Log.e(TAG, "Error logging in with Google", task.getException()); } } }); } }
Example 14
Source File: LoginActivity.java From android with MIT License | 5 votes |
private void handleGoogleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { // Signed in successfully final GoogleSignInAccount account = result.getSignInAccount(); runSocialLoginTask(Const.ApiValues.OAUTH_TYPE_GOOGLEPLUS, account.getIdToken()); } else if (result.getStatus().hasResolution()) { try { result.getStatus().startResolutionForResult(this, Const.RequestCodes.AUTH_LOGIN_GOOGLE_RESOLVE); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } } else { final Status status = result.getStatus(); if (status.isCanceled() || status.isInterrupted()) { return; } String msg = GoogleApiAvailability.getInstance() .getErrorString(status.getStatusCode()); if (TextUtils.isEmpty(msg)) { msg = String.valueOf(status.getStatusCode()); } final String message = String.format( getResources().getString(R.string.snackbar_auth_error_google), msg ); RedSnackbar.make(findViewById(R.id.root_view), message, Snackbar.LENGTH_LONG) .show(); } }
Example 15
Source File: GoogleHelper.java From argus-android with Apache License 2.0 | 5 votes |
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); if (acct != null) { listener.onSuccess(acct); } else { listener.onFailure("login failed"); } } else { // Signed out, show unauthenticated UI. // TODO Show correct message listener.onFailure("Error"); } }
Example 16
Source File: LoginActivity.java From aptoide-client with GNU General Public License v2.0 | 5 votes |
public void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "GoogleSignInResult. status: " + result.getStatus()); final GoogleSignInAccount account; if (result.isSuccess() && (account = result.getSignInAccount()) != null) { final String userName = account.getEmail(); final String token = account.getServerAuthCode(); final String name = account.getDisplayName(); submit(Mode.GOOGLE, userName, token, name); } else { Toast.makeText(Aptoide.getContext(), R.string.error_occured, Toast.LENGTH_SHORT).show(); } }
Example 17
Source File: LoginFragment.java From androidpay-quickstart with Apache License 2.0 | 5 votes |
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { Log.d(TAG, "googleSignIn:SUCCESS"); handleSignInSuccess(result.getSignInAccount()); } else { Log.d(TAG, "googleSignIn:FAILURE:" + result.getStatus()); Toast.makeText(getActivity(), R.string.network_error, Toast.LENGTH_LONG).show(); } }
Example 18
Source File: Login.java From UberClone with MIT License | 5 votes |
private void verifyGoogleAccount() { OptionalPendingResult<GoogleSignInResult> opr= Auth.GoogleSignInApi.silentSignIn(googleApiClient); if (opr.isDone()){ GoogleSignInResult result= opr.get(); if (result.isSuccess()) firebaseHelper.loginSuccess(); } }
Example 19
Source File: GoogleSignInDialogFragment.java From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void handleSignInResult(GoogleSignInResult result) { Log.d(Utils.TAG, "handleSignInResult:" + result.isSuccess()); hideProgressDialog(); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); Log.d(Utils.TAG, "handleSignInResult:" + acct.getEmail() + " " + acct.getDisplayName()); mServerAuthCode = acct.getServerAuthCode(); new RequestAccessTokenTask(getActivity(), mRequestAccessTokenCallback, "https://www.googleapis.com/oauth2/v4/token", getString(R.string.server_client_id), acct.getServerAuthCode()).execute(); } else { Toast.makeText(getActivity(), getString(R.string.google_sign_in_denied), Toast.LENGTH_LONG).show(); } }
Example 20
Source File: DriverTracking.java From UberClone with MIT License | 4 votes |
private void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { account = result.getSignInAccount(); } }