当前位置: 首页>>代码示例>>Java>>正文


Java AuthCredential类代码示例

本文整理汇总了Java中com.google.firebase.auth.AuthCredential的典型用法代码示例。如果您正苦于以下问题:Java AuthCredential类的具体用法?Java AuthCredential怎么用?Java AuthCredential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthCredential类属于com.google.firebase.auth包,在下文中一共展示了AuthCredential类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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

示例2: handleFacebookAccessToken

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    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:Shobhit-pandey,项目名称:CollegeDoc,代码行数:20,代码来源:MainActivity.java

示例3: handleTwitterSession

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
private void handleTwitterSession(TwitterSession session) {
    Log.d(TAG, "handleTwitterSession:" + session);

    AuthCredential credential = TwitterAuthProvider.getCredential(
            session.getAuthToken().token,
            session.getAuthToken().secret);

    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:Shobhit-pandey,项目名称:CollegeDoc,代码行数:27,代码来源:MainActivity.java

示例4: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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

示例5: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {

        Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

        showProgressDialog();

        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(SaveReports.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                        hideProgressDialog();
                    }
                });
    }
 
开发者ID:webianks,项目名称:Crimson,代码行数:23,代码来源:SaveReports.java

示例6: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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

示例7: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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

示例8: handleFacebookAccessToken

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
    LogUtil.logDebug(TAG, "handleFacebookAccessToken:" + token);
    showProgress();

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    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

示例9: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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

示例10: reauthenticate

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
private void reauthenticate() {
    // [START reauthenticate]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

    // Get auth credentials from the user for re-authentication. The example below shows
    // email and password credentials but there are multiple possible providers,
    // such as GoogleAuthProvider or FacebookAuthProvider.
    AuthCredential credential = EmailAuthProvider
            .getCredential("[email protected]", "password1234");

    // Prompt the user to re-provide their sign-in credentials
    user.reauthenticate(credential)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    Log.d(TAG, "User re-authenticated.");
                }
            });
    // [END reauthenticate]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:21,代码来源:MainActivity.java

示例11: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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

示例12: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的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:firebase,项目名称:friendlychat-android,代码行数:24,代码来源:SignInActivity.java

示例13: onActivityResult

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGNIN_GOOGLE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount account = result.getSignInAccount();
            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
            auth.signInWithCredential(credential)
                    .addOnCompleteListener(this, this);
        } else
            onFailure(result.getStatus().toString());
    } else
        callbackManager.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:17,代码来源:SigninActivity.java

示例14: firebaseAuthWithGoogle

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
private void firebaseAuthWithGoogle(GoogleSignInAccount account) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());
    showProgressDialog();
    AuthCredential credential = GoogleAuthProvider.getCredential(account.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());
                    hideProgressDialog();
                    // 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(AuthActivity.this, R.string.auth_failed,
                                Toast.LENGTH_SHORT).show();
                    }
                    // ...
                }
            });
}
 
开发者ID:braulio94,项目名称:Quadro,代码行数:23,代码来源:AuthActivity.java

示例15: handleAccessToken

import com.google.firebase.auth.AuthCredential; //导入依赖的package包/类
public void handleAccessToken(AccessToken token) {
	Utils.d("FB:Handle:AccessToken: " + token.getToken());
	// showProgressDialog();

	AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());

	mAuth.signInWithCredential(credential)
	.addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {

		@Override
		public void onComplete(@NonNull Task<AuthResult> task) {
			Utils.d("FB: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()) {
				Utils.w("FB:signInWithCredential" + 
					task.getException().toString());
			}

			// hideProgressDialog();
		}
	});
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:27,代码来源:FacebookSignIn.java


注:本文中的com.google.firebase.auth.AuthCredential类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。