本文整理汇总了Java中com.google.firebase.auth.GoogleAuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java GoogleAuthProvider类的具体用法?Java GoogleAuthProvider怎么用?Java GoogleAuthProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GoogleAuthProvider类属于com.google.firebase.auth包,在下文中一共展示了GoogleAuthProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
});
}
示例2: 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();
}
}
});
}
示例3: firebaseAuthWithGoogle
import com.google.firebase.auth.GoogleAuthProvider; //导入依赖的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();
}
});
}
示例4: 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);
}
});
}
示例5: 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();
}
// ...
}
});
}
示例6: 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);
}
}
});
}
示例7: 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();
}
}
});
}
示例8: 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();
}
}
});
}
示例9: onActivityResult
import com.google.firebase.auth.GoogleAuthProvider; //导入依赖的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);
}
示例10: firebaseAuthWithGoogle
import com.google.firebase.auth.GoogleAuthProvider; //导入依赖的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();
}
// ...
}
});
}
示例11: firebaseAuthWithGoogle
import com.google.firebase.auth.GoogleAuthProvider; //导入依赖的package包/类
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
Utils.d("Google:FirebaseAuthWithGoogle:" + acct.getId());
// FireBase.showProgressDialog();
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Utils.d(
"Google: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("Google:SignInWithCredential:" + task.getException());
}
// FireBase.hideProgressDialog();
}
});
}
示例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);
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(SignInActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
示例13: firebaseAuthWithGoogle
import com.google.firebase.auth.GoogleAuthProvider; //导入依赖的package包/类
@Override
public void firebaseAuthWithGoogle(final GoogleSignInAccount account) {
final AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(mContext, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
mLoginView.dismissProgress();
if (!task.isSuccessful()) {
mLoginView.showErrorMessage("Error In Create User");
} else {
FirebaseAuth.getInstance().getCurrentUser().linkWithCredential(credential);
String uid = task.getResult().getUser().getUid();
String name = account.getDisplayName();
String email = account.getEmail();
String imageProfileUrl = getHighQualityImage(account.getPhotoUrl());
createUserInFirebaseHelper(uid, new User(name, email, imageProfileUrl));
mLoginView.showMain();
}
}
});
}
示例14: 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(Authentication.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
示例15: 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);
}
});
}