本文整理汇总了Java中com.google.firebase.auth.FacebookAuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java FacebookAuthProvider类的具体用法?Java FacebookAuthProvider怎么用?Java FacebookAuthProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FacebookAuthProvider类属于com.google.firebase.auth包,在下文中一共展示了FacebookAuthProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的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();
}
}
});
}
示例2: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的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);
}
}
});
}
示例3: handleAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的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();
}
});
}
示例4: getCredential
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
public static AuthCredential getCredential(final JSONObject credential) throws Exception {
final String providerId = credential.getString("provider");
AuthCredential authCredential;
if (providerId.equals(EmailAuthProvider.PROVIDER_ID)) {
authCredential = getEmailAuthCredential(credential);
} else if (providerId.equals(FacebookAuthProvider.PROVIDER_ID)) {
authCredential = getFacebookAuthCredential(credential);
} else if (providerId.equals(GithubAuthProvider.PROVIDER_ID)) {
authCredential = getGithubAuthCredential(credential);
} else if (providerId.equals(GoogleAuthProvider.PROVIDER_ID)) {
authCredential = getGoogleAuthCredential(credential);
} else if (providerId.equals(TwitterAuthProvider.PROVIDER_ID)) {
authCredential = getTwitterAuthCredential(credential);
} else {
throw new Exception("Unknown provider ID: " + providerId);
}
return authCredential;
}
示例5: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的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) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
updateUI(mAuth.getCurrentUser());
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(LoginActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
示例6: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的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();
}
// ...
}
});
}
示例7: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
Log.d(TAG, "handleFacebookAccessToken:" + token);
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
fireBaseAuth.signInWithCredential(credential)
.addOnCompleteListener(getActivity(), 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(getApplicationContext(), "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
示例8: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
Log.e(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) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.e(TAG, "signInWithCredential:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUser(user);
updateUi();
} else {
// If sign in fails, display a message to the user.
Log.e(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(RegisterActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
示例9: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
Log.d(TAG, "handleFacebookAccessToken:" + token);
// [START_EXCLUDE silent]
// showProgressDialog();
// [END_EXCLUDE]
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
mAuth.signInWithCredential(credential)
.addOnCompleteListener(getActivity(), 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(getContext(), "Authentication failed.", Toast.LENGTH_SHORT).show();
}
// [START_EXCLUDE]
// hideProgressDialog();
dismiss();
// [END_EXCLUDE]
}
});
}
示例10: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
auth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(LoginTempActivity.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();
}
}
});
}
示例11: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
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();
}
}
});
}
示例12: handleFacebookAccessToken
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
private void handleFacebookAccessToken(AccessToken token) {
Log.d("hfat", "handleFacebookAccessToken:" + token);
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
auth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("hfat - o", "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("hfat - o is", "signInWithCredential", task.getException());
Toast.makeText(RegisterActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
示例13: onSuccess
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
@Override
public void onSuccess(LoginResult loginResult) {
Timber.d("facebook:onSuccess:permissions" + loginResult.getRecentlyGrantedPermissions());
AuthCredential credential = FacebookAuthProvider.getCredential(loginResult.getAccessToken().getToken());
firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Timber.d("onComplete:failed:" + task.getException());
return;
}
Timber.d("onComplete:success:" + task.isSuccessful());
sessionManager.saveUserInfo();
setupLoginState();
}
});
}
示例14: doInBackground
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if(user != null) {
for(UserInfo info : user.getProviderData()) {
switch(info.getProviderId()) {
case GoogleAuthProvider.PROVIDER_ID:
logoutGoogle();
break;
case FacebookAuthProvider.PROVIDER_ID:
logoutFacebook();
break;
case TwitterAuthProvider.PROVIDER_ID:
logoutTwitter();
break;
}
}
FirebaseAuth.getInstance().signOut();
}
return null;
}
示例15: facebookLogin
import com.google.firebase.auth.FacebookAuthProvider; //导入依赖的package包/类
@ReactMethod
public void facebookLogin(String Token, final Callback callback) {
mAuth = FirebaseAuth.getInstance();
AuthCredential credential = FacebookAuthProvider.getCredential(Token);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirestackAuthModule.this.user = task.getResult().getUser();
userCallback(FirestackAuthModule.this.user, callback);
}else{
// userErrorCallback(task, callback);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception ex) {
userExceptionCallback(ex, callback);
}
});
}