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


Java TwitterAuthProvider.getCredential方法代码示例

本文整理汇总了Java中com.google.firebase.auth.TwitterAuthProvider.getCredential方法的典型用法代码示例。如果您正苦于以下问题:Java TwitterAuthProvider.getCredential方法的具体用法?Java TwitterAuthProvider.getCredential怎么用?Java TwitterAuthProvider.getCredential使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.auth.TwitterAuthProvider的用法示例。


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

示例1: handleTwitterSession

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

示例2: handleTwitterSession

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private void handleTwitterSession(TwitterSession session) {
	Utils.d("Twitter:HandleSession:" + session);

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

	mAuth.signInWithCredential(credential)
	.addOnCompleteListener(activity, 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
				Utils.d("signInWithCredential:success");
			} else {
				// If sign in fails, display a message to the user.
				Utils.w("signInWithCredential:failure: " + task.getException());
			}

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

示例3: twitterLogin

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
@ReactMethod
public void twitterLogin(String Token, String Secret, final Callback callback) {
    mAuth = FirebaseAuth.getInstance();

    AuthCredential credential = TwitterAuthProvider.getCredential(Token, Secret);
    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);
          }
        });
}
 
开发者ID:fullstackreact,项目名称:react-native-firestack,代码行数:24,代码来源:FirestackAuth.java

示例4: handleTwitterSession

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
void handleTwitterSession(TwitterSession session) {
    Timber.d("handleTwitterSession:" + session);

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

    mAuth.signInWithCredential(credential)
            .addOnCompleteListener((Activity) mContext, task -> {
                Timber.d("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()) {
                    Timber.w("signInWithTwitterCredential", task.getException());
                    mEventBus.post(new LoginEvent(false, "Twitter Auth Failed : " + task.getException().getMessage()));
                } else {
                    Timber.w("signInWithTwitterCredential", "success with email " + task.getResult().getUser().getEmail());
                    mEventBus.post(new LoginEvent(true, "Twitter Auth Success"));
                }
            });
}
 
开发者ID:derohimat,项目名称:FirebaseAuthExample,代码行数:24,代码来源:LoginPresenter.java

示例5: handleTwitterSession

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private void handleTwitterSession(TwitterSession session) {
    AuthCredential credential = TwitterAuthProvider.getCredential(session.getAuthToken().token, session.getAuthToken().secret);
    if (mAuth.getCurrentUser() == null) {
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(LoginActivity.this, new LoginCallback(LoginActivity.this, false, "connect_to_twitter"));
    } else {
        mAuth.getCurrentUser()
                .linkWithCredential(credential)
                .addOnCompleteListener(LoginActivity.this, new LoginCallback(LoginActivity.this, true, "connect_to_twitter"));
    }
}
 
开发者ID:cache117,项目名称:social-journal,代码行数:12,代码来源:LoginActivity.java

示例6: handleTwitterSession

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private void handleTwitterSession(TwitterSession session) {
    AuthCredential credential = TwitterAuthProvider.getCredential(session.getAuthToken().token, session.getAuthToken().secret);
    if (mAuth.getCurrentUser() == null) {
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new LoginCallback(this, false, "connect_to_twitter"));
    } else {
        mAuth.getCurrentUser()
                .linkWithCredential(credential)
                .addOnCompleteListener(this, new LoginCallback(this, true, "connect_to_twitter"));
    }
}
 
开发者ID:cache117,项目名称:social-journal,代码行数:12,代码来源:SettingsActivity.java

示例7: handleTwitterSession

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private void handleTwitterSession(TwitterSession session) {
    Log.d(TAG, "handleTwitterSession:" + session);
    // [START_EXCLUDE silent]
    showProgressDialog();
    // [END_EXCLUDE]

    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) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUI(user);
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(TwitterLoginActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }

                    // [START_EXCLUDE]
                    hideProgressDialog();
                    // [END_EXCLUDE]
                }
            });
}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:34,代码来源:TwitterLoginActivity.java

示例8: handleTwitterSession

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private void handleTwitterSession(TwitterSession session) {
    Log.d(TAG, "handleTwitterSession:" + session);
    // [START_EXCLUDE silent]
    showProgressDialog();
    // [END_EXCLUDE]

    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(TwitterLoginActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // [START_EXCLUDE]
                    hideProgressDialog();
                    // [END_EXCLUDE]
                }
            });
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-samples,代码行数:32,代码来源:TwitterLoginActivity.java

示例9: signInTwitter

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private void signInTwitter(String token, String secret) {

        AuthCredential credential = TwitterAuthProvider.getCredential(token, secret);
        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(getActivity(), "Authentication failed.",
                            Toast.LENGTH_SHORT).show();
                    getActivity().finish();
                } else {
                    user = task.getResult().getUser();
                    registerUserInDatabase();
                    if (listener != null) {
                        Bundle bundle = new Bundle();
                        listener.onFragmentInteraction(Constants.SIGN_UP_FRAGMENT, bundle);
                    } else {
                        getActivity().finish();
                    }
                }

            }
        });

    }
 
开发者ID:juanjecilla,项目名称:FindMeAHome,代码行数:32,代码来源:SignUpFragment.java

示例10: firebaseAuthWithTwitter

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
/**
 * Authenticate with Firebase using a Twitter token.
 *
 * @param session The TwitterSession
 */
private void firebaseAuthWithTwitter(@NonNull TwitterSession session) {
    final AuthCredential credential = TwitterAuthProvider.getCredential(
            session.getAuthToken().token,
            session.getAuthToken().secret);
    mAuth.signInWithCredential(credential);
}
 
开发者ID:ultramega,项目名称:flavordex,代码行数:12,代码来源:LoginActivity.java

示例11: reauthenticateWithCredentialForProvider

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
@ReactMethod
public void reauthenticateWithCredentialForProvider(final String provider, final String authToken, final String authSecret, final Callback callback) {
    AuthCredential credential;

    if (provider.equals("facebook")) {
        credential = FacebookAuthProvider.getCredential(authToken);
    } else if (provider.equals("google")) {
        credential = GoogleAuthProvider.getCredential(authToken, null);
    } else if (provider.equals("twitter")) {
        credential = TwitterAuthProvider.getCredential(authToken, authSecret);
    } else {
        // TODO:
        FirestackUtils.todoNote(TAG, "reauthenticateWithCredentialForProvider", callback);
        // AuthCredential credential;
        // Log.d(TAG, "reauthenticateWithCredentialForProvider called with: " + provider);
        return;
    }

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        user.reauthenticate(credential)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        Log.d(TAG, "User re-authenticated with " + provider);
                        FirebaseUser u = FirebaseAuth.getInstance().getCurrentUser();
                        userCallback(u, callback);
                    } else {
                        // userErrorCallback(task, callback);
                    }
                }
            });
    } else {
        WritableMap err = Arguments.createMap();
        err.putInt("errorCode", NO_CURRENT_USER);
        err.putString("errorMessage", "No current user");
        callback.invoke(err);
    }
}
 
开发者ID:fullstackreact,项目名称:react-native-firestack,代码行数:41,代码来源:FirestackAuth.java

示例12: getAuthCredential

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
@Nullable
public static AuthCredential getAuthCredential(IdpResponse response) {
    switch (response.getProviderType()) {
        case GoogleAuthProvider.PROVIDER_ID:
            return GoogleAuthProvider.getCredential(response.getIdpToken(), null);
        case FacebookAuthProvider.PROVIDER_ID:
            return FacebookAuthProvider.getCredential(response.getIdpToken());
        case TwitterAuthProvider.PROVIDER_ID:
            return TwitterAuthProvider.getCredential(response.getIdpToken(),
                    response.getIdpSecret());
        default:
            return null;
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:15,代码来源:ProviderUtils.java

示例13: getTwitterAuthCredential

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
private static AuthCredential getTwitterAuthCredential(final JSONObject credential) throws Exception {
    final String token = credential.getString("token");
    final String secret = credential.getString("secret");
    return TwitterAuthProvider.getCredential(token, secret);
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:6,代码来源:AuthCredentials.java

示例14: createAuthCredential

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
public static AuthCredential createAuthCredential(IdpResponse response) {
    if (!response.getProviderType().equalsIgnoreCase(TwitterAuthProvider.PROVIDER_ID)) {
        return null;
    }
    return TwitterAuthProvider.getCredential(response.getIdpToken(), response.getIdpSecret());
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:7,代码来源:TwitterProvider.java

示例15: loginTwitter

import com.google.firebase.auth.TwitterAuthProvider; //导入方法依赖的package包/类
/**
 * Method get the Rx function to generate credential form FireBase
 *
 * @param token,secret Twitter credentials to generate the credential to fireBase
 * @return Observable<User>
 */
@Override
public Observable<User> loginTwitter(String token, String secret) {
    AuthCredential credential = TwitterAuthProvider.getCredential(token, secret);
    return loginWithCredentials(credential);
}
 
开发者ID:scott7462,项目名称:Udacity-Capstone-Project,代码行数:12,代码来源:SessionFireBaseData.java


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