本文整理汇总了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();
}
// ...
}
});
}
示例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());
}
// ...
}
});
}
示例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);
}
});
}
示例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"));
}
});
}
示例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"));
}
}
示例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"));
}
}
示例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]
}
});
}
示例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]
}
});
}
示例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();
}
}
}
});
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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());
}
示例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);
}