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


Java AuthData类代码示例

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


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

示例1: generateAnonymousAccount

import com.firebase.client.AuthData; //导入依赖的package包/类
/**
 * Generate an anonymous account to identify this user. The UID will be transmitted as part of the payload for all
 * connected devices.
 */
private void generateAnonymousAccount() {
    LogUtils.LOGE("***> generate anon account", "here");
    Firebase ref = new Firebase(Constants.FIREBASE_URL);
    ref.authAnonymously(new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            // we've authenticated this session with your Firebase app
            LogUtils.LOGE("***> onAuthenticated", authData.getUid());
            PreferencesUtils.setString(mActivity, R.string.key_firebase_uid, authData.getUid());
            createUserInFirebaseHelper(authData.getUid());
        }
        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            // there was an error
        }
    });
}
 
开发者ID:kyleparker,项目名称:io16experiment-master,代码行数:22,代码来源:MainActivity.java

示例2: setAuthenticatedUser

import com.firebase.client.AuthData; //导入依赖的package包/类
/**
 * Once a user is logged in, take the mAuthData provided from Firebase and "use" it.
 */
private void setAuthenticatedUser(AuthData authData) {
    if (authData != null) {
        /* Hide all the login buttons */

        /* show a provider specific status text */
        String name = null;
        if (authData.getProvider().equals("password")) {
            name = authData.getUid();
        } else {
            Log.e(TAG, "Invalid provider: " + authData.getProvider());
        }
        if (name != null) {
            Log.d(TAG, "Logged in as " + name + " (" + authData.getProvider() + ")");
        }
    } else {

    }
    this.mAuthData = authData;
}
 
开发者ID:benslamajihed,项目名称:GalleryPictureFirebaseAndroid,代码行数:23,代码来源:GalleryActivity.java

示例3: authenticate

import com.firebase.client.AuthData; //导入依赖的package包/类
/**
 * @param appData {@link AppData} object which contains the token to authenticate with.
 * @param reAuth  True if this is a re-authentication attempt.
 * @return An {@link AuthData} object.
 */
public Task<AppData> authenticate(AppData appData, boolean reAuth) {
    Task<AppData>.TaskCompletionSource taskSource = Task.<AppData>create();

    firebaseRef.authWithCustomToken(appData.getFirebaseConfig().getToken(), new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            if (reAuth) {
                userManager.setLoggedIn(appData.getUser().getUsername());
            }

            taskSource.setResult(appData);
        }

        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            taskSource.setError(firebaseError.toException());
        }
    });

    return taskSource.getTask();
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:27,代码来源:FirebaseTasks.java

示例4: setAuthenticatedUser

import com.firebase.client.AuthData; //导入依赖的package包/类
/**
 * Once a user is logged in, take the mAuthData provided from Firebase and "use" it.
 */
private void setAuthenticatedUser(AuthData authData) {
    if (authData != null) {
        if (authData.getProvider().equals(Constants.GOOGLE_PROVIDER)) {
            mSharedPreferences.edit().putString(Constants.KEY_PROVIDER, authData.getProvider()).apply();
            mSharedPreferences.edit().putString(Constants.KEY_USER_UID, authData.getUid()).apply();
        } else {
            showErrorDialog(getString(R.string.login_activity_error_message_invalid_provider, authData.getProvider()));
        }

        Map<String, Object> map = new HashMap<>();
        map.put(Constants.FIREBASE_USER_NAME, mSharedPreferences.getString(Constants.KEY_DISPLAY_NAME, null));
        map.put(Constants.FIREBASE_USER_EMAIL, mSharedPreferences.getString(Constants.KEY_EMAIL, null));
        new Firebase(Utils.getFirebaseUserUrl(authData.getUid()))
                .updateChildren(map);

        /* Go to main activity */
        Intent intent = new Intent(LoginActivity.this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
        finish();
    }
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:26,代码来源:LoginActivity.java

示例5: login

import com.firebase.client.AuthData; //导入依赖的package包/类
@Override
public void login(String username, String password) {

    final Firebase myFirebaseRef = RegLog.getFirebase();

    myFirebaseRef.authWithPassword(username, password, new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            System.out.println("Successfully authenticated with uid: " + authData.getUid());
            EventBus.getDefault().post(new LoginCallbackEvent(true, null));
        }

        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            EventBus.getDefault().post(new LoginCallbackEvent(false, firebaseError.getMessage()));
        }
    });
}
 
开发者ID:Antpachon,项目名称:RegLog,代码行数:19,代码来源:LoginServiceFirebaseImpl.java

示例6: onLoginClick

import com.firebase.client.AuthData; //导入依赖的package包/类
public void onLoginClick(View view)
{
    EditText passwordField = (EditText) findViewById(R.id.initial_password);
    EditText emailField = (EditText) findViewById(R.id.initial_email);

    rootReference.authWithPassword(emailField.getText().toString(), passwordField.getText().toString(), new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            Intent intent = new Intent(getApplicationContext(), MapsActivity.class);
            intent.putExtra("locLat",mLastLocation.getLatitude());
            intent.putExtra("locLong", mLastLocation.getLongitude());
            startActivity(intent);
        }
        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
           Toast.makeText(getApplicationContext(), "Error logging in", Toast.LENGTH_LONG);
        }
    });
}
 
开发者ID:StephenVanSon,项目名称:TutorMe,代码行数:20,代码来源:InitialActivity.java

示例7: logout

import com.firebase.client.AuthData; //导入依赖的package包/类
private void logout(AuthData authData) {

        this.mAuthData = authData;

        if (this.mAuthData != null) {
            /* logout of Firebase */
            ref.unauth();
            /* Logout of any of the Frameworks. This step is optional, but ensures the user is not logged into
             * Facebook/Google+ after logging out of Firebase. */
            if (this.mAuthData.getProvider().equals("facebook")) {
                /* Logout from Facebook */
                LoginManager.getInstance().logOut();
            } else if (this.mAuthData.getProvider().equals("google")) {
                /* Logout from Google+ */
                if (mGoogleApiClient.isConnected()) {
                    Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
                    mGoogleApiClient.disconnect();
                }
            }
            /* Update authenticated user and show login buttons */
//            setAuthenticatedUser(null);
        }
    }
 
开发者ID:blessingoraz,项目名称:Akwukwo,代码行数:24,代码来源:ViewPageActivity.java

示例8: onFirebaseLoggedIn

import com.firebase.client.AuthData; //导入依赖的package包/类
@Override
public void onFirebaseLoggedIn(AuthData authData) {
    View loginContentView = mRootView.findViewById(R.id.login_content);
    ProgressBar loginProgressBar = (ProgressBar) mRootView.findViewById(R.id.login_progressbar);

    loginContentView.setVisibility(View.GONE);
    loginProgressBar.setVisibility(View.VISIBLE);

    if(LOG_SHOW) Log.i(LOG_TAG, "Logged in using " + authData.getProvider());

    // returned data
    if(LOG_SHOW) Log.i(LOG_TAG, "Login data: " + authData.toString());

    // This code fires when a user is newly created using the LoginRegisterDialog
    // because it contains an Auth listener. User creation is handled by the dialog code
    //
    // If the account is not being created: check to see if the user exists
    // if not, add user to database, if it does completeLogin (called from
    // checkForUser because of listener)
    if(!creatingAccount) checkForUser(authData);
}
 
开发者ID:cardenuto,项目名称:FirebaseLogin,代码行数:22,代码来源:LoginActivity.java

示例9: addUserInfo

import com.firebase.client.AuthData; //导入依赖的package包/类
public String addUserInfo(AuthData authData) {
    //TODO: (Optional) Update for any new fields added to DbUserInfo class
    // set user id
    String uid = authData.getUid();

    // create record
    String provider = authData.getProvider();
    String email = getResources().getString(R.string.missing_user_data);
    String profileImageUrl = getResources().getString(R.string.missing_user_data);
    String displayName = getResources().getString(R.string.missing_user_data);

    if(authData.getProviderData().containsKey("email")) email = authData.getProviderData().get("email").toString();
    if(authData.getProviderData().containsKey("profileImageURL")) profileImageUrl = authData.getProviderData().get("profileImageURL").toString();
    if(authData.getProviderData().containsKey("displayName")) displayName = authData.getProviderData().get("displayName").toString();

    // define users
    DbUserInfo newUserInfo = new DbUserInfo(provider, email, profileImageUrl, displayName);
    Firebase pushUser = mRef.child("userInfo/users").push();
    pushUser.setValue(newUserInfo);

    // define userMap
    populateUserMap(mRef, uid, pushUser.getKey());

    return pushUser.getKey();
}
 
开发者ID:cardenuto,项目名称:FirebaseLogin,代码行数:26,代码来源:LoginActivity.java

示例10: onFirebaseLoggedIn

import com.firebase.client.AuthData; //导入依赖的package包/类
@Override
protected void onFirebaseLoggedIn(AuthData authData) {
    super.onFirebaseLoggedIn(authData);

    switch (authData.getProvider()){
        case "facebook":
            email = authData.getProviderData().get("displayName")+"";
            break;
        case "password":
            if(BuildConfig.DEBUG) {
                Log.d("Firebase", authData.getProviderData().get("email") + "");
            }
            email = authData.getProviderData().get("email")+"";
            break;
    }

    loginButton.setVisibility(View.GONE);
    logoutButton.setVisibility(View.VISIBLE);
}
 
开发者ID:khacpv,项目名称:CodeLab-Firebase-VN,代码行数:20,代码来源:MainActivity.java

示例11: observeAuth

import com.firebase.client.AuthData; //导入依赖的package包/类
public static Observable<AuthData> observeAuth(final Firebase firebase){
    return Observable.create(new Observable.OnSubscribe<AuthData>() {
        @Override
        public void call(final Subscriber<? super AuthData> subscriber) {
            final Firebase.AuthStateListener listener = firebase.addAuthStateListener(new Firebase.AuthStateListener() {
                @Override
                public void onAuthStateChanged(AuthData authData) {
                    subscriber.onNext(authData);
                }
            });

            subscriber.add(Subscriptions.create(new Action0() {
                @Override
                public void call() {
                    firebase.removeAuthStateListener(listener);
                }
            }));
        }
    }).startWith(firebase.getAuth()).distinctUntilChanged();
}
 
开发者ID:DariusL,项目名称:RxFirebaseAndroid,代码行数:21,代码来源:RxFirebase.java

示例12: loginWithUserName

import com.firebase.client.AuthData; //导入依赖的package包/类
@Override
 public void loginWithUserName(String username, String password) {

     Firebase ref = new Firebase(TreepolisConsts.FIREBASE_TREEPOLIS_URL);

     Firebase.AuthResultHandler authResultHandler = new Firebase.AuthResultHandler() {
         @Override
         public void onAuthenticated(AuthData authData) {
             if(mListener != null) {
                 mListener.onLoginSuccessful();
             }
         }
         @Override
         public void onAuthenticationError(FirebaseError firebaseError) {
             if(mListener != null) {
                 mListener.onLoginError(firebaseError);
             }
         }
     };

     ref.authWithPassword(username, password, authResultHandler);
}
 
开发者ID:Quoders,项目名称:treepolis-android,代码行数:23,代码来源:WelcomeInteractorImpl.java

示例13: performLogin

import com.firebase.client.AuthData; //导入依赖的package包/类
private void performLogin(String email, String password) {
    Firebase ref = new Firebase(TreepolisConsts.FIREBASE_TREEPOLIS_URL);

    Firebase.AuthResultHandler authResultHandler = new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            if(mListener != null) {
                mListener.onSignupSuccess();
            }
        }
        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            if(mListener != null) {
                mListener.onLoginErrorAfterSignup();
            }
        }
    };

    ref.authWithPassword(email, password, authResultHandler);
}
 
开发者ID:Quoders,项目名称:treepolis-android,代码行数:21,代码来源:SignupInteractorImpl.java

示例14: onCreate

import com.firebase.client.AuthData; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url));

    mFirebaseRef.addAuthStateListener(new Firebase.AuthStateListener() {
        @Override
        public void onAuthStateChanged(AuthData authData) {
            if (authData != null) {
                Firebase ref = mFirebaseRef.child("users").child(authData.getUid());
                ref.keepSynced(true);
                mListAdapter = new ClimbSessionListAdapter(ref.child("climbs").limitToLast(CLIMB_LIMIT).orderByChild("date"), R.layout.climbsession_item, getActivity());
                setListAdapter(mListAdapter);
            }
        }
    });

}
 
开发者ID:google,项目名称:climb-tracker,代码行数:20,代码来源:ClimbSessionListFragment.java

示例15: onCreate

import com.firebase.client.AuthData; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Analytics.
    ClimbTrackerApplication application = (ClimbTrackerApplication) getActivity().getApplication();
    mTracker = application.getDefaultTracker();

    // track pageview
    mTracker.setScreenName(LOG_TAG);
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());

    mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url));
    AuthData authData = mFirebaseRef.getAuth();
    mFirebaseRef = mFirebaseRef.child("users")
            .child(authData.getUid())
            .child("climbs");


    long time = getArguments().getLong(ARG_FIRST_CLIMB_TIME);
    mSession = new ClimbSession( new Date(time) );

    long lastTime = getArguments().getLong(ARG_LAST_CLIMB_TIME);

    mListAdapter = new ClimbListAdapter(mFirebaseRef.limitToFirst(50).orderByChild("date").startAt(time).endAt(lastTime), R.layout.climb_item, getActivity());
}
 
开发者ID:google,项目名称:climb-tracker,代码行数:27,代码来源:ClimbSessionDetailFragment.java


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