當前位置: 首頁>>代碼示例>>Java>>正文


Java GoogleAuthProvider.getCredential方法代碼示例

本文整理匯總了Java中com.google.firebase.auth.GoogleAuthProvider.getCredential方法的典型用法代碼示例。如果您正苦於以下問題:Java GoogleAuthProvider.getCredential方法的具體用法?Java GoogleAuthProvider.getCredential怎麽用?Java GoogleAuthProvider.getCredential使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.firebase.auth.GoogleAuthProvider的用法示例。


在下文中一共展示了GoogleAuthProvider.getCredential方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {

        AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        auth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d("HERE", "signInWithCredential:onComplete:" + task.isSuccessful());
                        Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
                        startActivity(intent);
                        finish();

                        // If sign in fails, display a message to the user. If sign in succeeds
                        // the auth state listener will be notified and logic to handle the
                        // signed in user can be handled in the listener.
                        if (!task.isSuccessful()) {
                            Log.w("HERE", "signInWithCredential", task.getException());
                            Toast.makeText(LoginActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                    }
                });
    }
 
開發者ID:mremondi,項目名稱:Hyke,代碼行數:24,代碼來源:LoginActivity.java

示例2: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
        Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

        AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            hideProgressDialog();
                            // Sign in success, update UI with the signed-in user's information
                            Log.d(TAG, "signInWithCredential:success");
//                            FirebaseUser user = mAuth.getCurrentUser();
                            startApp();
                        } else {
                            hideProgressDialog();
                            // If sign in fails, display a message to the user.
                            Log.w(TAG, "signInWithCredential:failure", task.getException());
                            Toast.makeText(BaseAuthActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }

                        // ...
                    }
                });
    }
 
開發者ID:mangoblogger,項目名稱:MangoBloggerAndroidApp,代碼行數:27,代碼來源:BaseAuthActivity.java

示例3: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    LogUtil.logDebug(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    showProgress();

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    LogUtil.logDebug(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        handleAuthError(task);
                    }
                }
            });
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:21,代碼來源:LoginActivity.java

示例4: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    MyLg.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()+" "+acct.getPhotoUrl());
    showProgressDialog();

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    MyLg.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        MyLg.w(TAG, "signInWithCredential");
                        Toas.show(context, "Authentication failed.");
                    }
                    hideProgressDialog();
                }
            });
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:23,代碼來源:SignInBaseActivity.java

示例5: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
@Override
public void firebaseAuthWithGoogle(GoogleSignInAccount account,
                                   final Callbacks.IResultCallback<Usuario> callback) {
    showLog("firebaseAuthWithGoogle: " + account.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
    FirebaseAuth.getInstance()
            .signInWithCredential(credential)
            .addOnFailureListener( reportError(callback))
            .addOnSuccessListener(new OnSuccessListener<AuthResult>() {
                @Override
                public void onSuccess(AuthResult authResult) {
                    FirebaseUser user = authResult.getUser();
                    loginFlow( user, callback);
                }
            });
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:17,代碼來源:UserRemoteDataSource.java

示例6: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        startActivity(new Intent(SignInActivity.this, MainActivity.class));
                        finish();
                    }
                }
            });
}
 
開發者ID:YoWenqin,項目名稱:BuddiesGo,代碼行數:24,代碼來源:SignInActivity.java

示例7: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    progress = ProgressDialog.show(this, "Login...",
            "", true);
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, task -> {
                if (task.isSuccessful()) {
                    currentUser =  mAuth.getCurrentUser();
                    Log.e(TAG, "signInWithCredential:success");
                    loadRooms();
                    updateUI(currentUser);
                } else {
                    Log.e(TAG, "signInWithCredential:failure", task.getException());
                    Toast.makeText(LoginActivity.this, "Authentication failed.",
                            Toast.LENGTH_SHORT).show();
                    updateUI(null);
                }
            });
}
 
開發者ID:YoungPeacock,項目名稱:FantaF1,代碼行數:21,代碼來源:LoginActivity.java

示例8: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    showProgressDialog(getString(R.string.profile_progress_message));
    mAuth.signInWithCredential(credential)
            .addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
                @Override
                public void onSuccess(AuthResult result) {
                    handleFirebaseAuthResult(result);
                }
            })
            .addOnFailureListener(this, new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    FirebaseCrash.logcat(Log.ERROR, TAG, "auth:onFailure:" + e.getMessage());
                    handleFirebaseAuthResult(null);
                }
            });
}
 
開發者ID:firebase,項目名稱:friendlypix-android,代碼行數:20,代碼來源:ProfileActivity.java

示例9: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
@Override
public void firebaseAuthWithGoogle(GoogleSignInAccount acct,final OnLoginFinishedListener listener) {

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        listener.onLoginGoogleFail();
                    }

                }
            });
}
 
開發者ID:jcolladosp,項目名稱:PimPam,代碼行數:20,代碼來源:LoginInteractorImpl.java

示例10: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                    // ...
                }
            });
}
 
開發者ID:othreecodes,項目名稱:WaJeun,代碼行數:23,代碼來源:MainActivity.java

示例11: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount account) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(LoginScreen.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    } else{
                        startActivity(new Intent(LoginScreen.this, MainActivity.class));
                        finish();
                    }
                }
            });
}
 
開發者ID:ThisChessPlayer,項目名稱:GroupScheduleCoordinator,代碼行數:25,代碼來源:LoginScreen.java

示例12: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        startActivity(new Intent(SignInActivity.this, MainActivity.class));
                        finish();
                    }
                }
            });
}
 
開發者ID:jrkt,項目名稱:FireChat,代碼行數:24,代碼來源:SignInActivity.java

示例13: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    mProgress.setMessage("Realizando login...");
    mProgress.show();

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    mProgress.dismiss();

                    if(!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    if(task.isSuccessful()) {
                        checkUserExist();
                    }
                }
            });
}
 
開發者ID:kaiomax,項目名稱:RUSpotlight,代碼行數:27,代碼來源:MainActivity.java

示例14: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    // [START_EXCLUDE silent]
    showProgressDialog();
    // [END_EXCLUDE]

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(GoogleSignActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                    // [START_EXCLUDE]
                    hideProgressDialog();
                    // [END_EXCLUDE]
                }
            });
}
 
開發者ID:siosio34,項目名稱:AR-Trace,代碼行數:25,代碼來源:GoogleSignActivity.java

示例15: firebaseAuthWithGoogle

import com.google.firebase.auth.GoogleAuthProvider; //導入方法依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    auth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (!task.isSuccessful()) {
                        Toast.makeText(LoginActivity.this, R.string.error_auth,
                                Toast.LENGTH_SHORT).show();
                        showMainScreen();
                    }else{
                        FirebaseUser firebaseUser = task.getResult().getUser();
                        User user = new User();
                        user.setDisplayName(firebaseUser.getDisplayName());
                        user.setEmail(firebaseUser.getEmail());
                        user.setId(firebaseUser.getUid());
                        if(firebaseUser.getPhotoUrl() != null){
                            user.setProfileImageURL(firebaseUser.getPhotoUrl().toString());
                        }
                        user.setToken(user.getToken());
                        repository.saveUser(user);
                        showMainScreen();
                    }
                }
            });
}
 
開發者ID:douglasmarques,項目名稱:survey-android,代碼行數:27,代碼來源:LoginActivity.java


注:本文中的com.google.firebase.auth.GoogleAuthProvider.getCredential方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。