handleFacebookAccessToken:{AccessToken令牌:ACCESS_TOKEN_REMOVED权限:[public_profile,user_friends,email]}

时间:2017-04-17 16:59:05

标签: android facebook facebook-graph-api firebase firebase-authentication

在为调试目的创建签名的apk之前,每件事都运行正常。我能够从facebook登录。但是突然发生了什么事情都没有想法(只有我做的事情是用调试sha1键限制我的谷歌地图api键)。我在facebook登录时使用firebase。这是我的错误:

04-17 21:38:35.628 4362-9601/com.example.rishabh.stareout D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=144814, _sc=IntroActivity, _si=886567669576019156}]
04-17 21:38:35.715 17721-9615/? V/FA-SVC: Event recorded: Event{appId='com.example.rishabh.stareout', name='_e', params=Bundle[{_o=auto, _et=144814, _sc=IntroActivity, _si=886567669576019156}]}
04-17 21:40:41.687 4362-4362/com.example.rishabh.stareout D/IntroActivity: onAuthStateChanged:signed_out
04-17 21:40:42.491 1956-2056/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{a365a50 u0 com.example.rishabh.stareout/.IntroActivity t4710} time:195347814
04-17 21:40:47.595 4362-12316/com.example.rishabh.stareout D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=5897, _sc=IntroActivity, _si=886567669576019156}]
04-17 21:40:47.748 17721-12319/? V/FA-SVC: Event recorded: Event{appId='com.example.rishabh.stareout', name='_e', params=Bundle[{_o=auto, _et=5897, _sc=IntroActivity, _si=886567669576019156}]}
04-17 21:40:55.493 4362-4362/com.example.rishabh.stareout D/IntroActivity: facebook:onSuccess:com.facebook.login.LoginResult@5a00296
04-17 21:40:55.493 4362-4362/com.example.rishabh.stareout D/IntroActivity: handleFacebookAccessToken:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[public_profile, user_friends, email]}
04-17 21:40:56.190 4362-4362/com.example.rishabh.stareout D/IntroActivity: signInWithCredential:onComplete:false
04-17 21:40:56.190 4362-4362/com.example.rishabh.stareout W/IntroActivity: signInWithCredential
com.google.firebase.FirebaseException: An internal error has occurred. [ Bad Request ]                             
    at com.google.android.gms.internal.zzblv.zzce(Unknown Source)       
    at com.google.android.gms.internal.zzbls$zzj.zza(Unknown Source)
    at com.google.android.gms.internal.zzbmd.zzcf(Unknown Source)
    at com.google.android.gms.internal.zzbmd$zza.onFailure(Unknown Source)
    at com.google.android.gms.internal.zzbly$zza.onTransact(Unknown Source)
    at android.os.Binder.execTransact(Binder.java:453)

刚刚举行祝词“身份验证失败”。 我正在使用firebase文档本身的facebook登录代码:

mCallbackManager = CallbackManager.Factory.create();
        loginButton = (LoginButton) findViewById(R.id.button_facebook_login);
        loginButton.setReadPermissions("email", "public_profile", "user_friends");
        loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                Log.d(TAG, "facebook:onSuccess:" + loginResult);

                new GraphRequest(
                        AccessToken.getCurrentAccessToken(),
                        "/me/friends",
                        null,
                        HttpMethod.GET,
                        new GraphRequest.Callback() {
                            public void onCompleted(GraphResponse response) {

                                try {
                                    JSONArray rawName = response.getJSONObject().getJSONArray("data");
                                    jsondata = rawName.toString();

                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }

                            }
                        }
                ).executeAsync();

                handleFacebookAccessToken(loginResult.getAccessToken());
            }

            @Override
            public void onCancel() {
                Log.d(TAG, "facebook:onCancel");
                // ...
            }

            @Override
            public void onError(FacebookException error) {
                Log.d(TAG, "facebook:onError", error);
                // ...
            }
        });

    }

    @Override
    public void onStart() {
        super.onStart();
        mAuth.addAuthStateListener(mAuthListener);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Pass the activity result back to the Facebook SDK
        mCallbackManager.onActivityResult(requestCode, resultCode, data);
    }


    private void handleFacebookAccessToken(AccessToken token) {
        Log.d(TAG, "handleFacebookAccessToken:" + token);
        mProgress.setMessage("Logging in...");
        mProgress.show();

        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(IntroActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                            mProgress.dismiss();
                        }else{

                            String name=task.getResult().getUser().getDisplayName();
                            String email=task.getResult().getUser().getEmail();
                            String image=task.getResult().getUser().getPhotoUrl().toString();

                            DatabaseReference childRef = mUserRef.child(Profile.getCurrentProfile().getId());
                            childRef.child("name").setValue(name);
                            childRef.child("email").setValue(email);
                            childRef.child("image").setValue(image);

                            FirebaseMessaging.getInstance().subscribeToTopic(Profile.getCurrentProfile().getId());
                            FirebaseDatabase.getInstance().getReference().child("CheckIfNotification").child(Profile.getCurrentProfile().getId()).setValue(false);


                            JSONArray friendList;
                            try {

                                DatabaseReference childFriendRef = childRef.child("friends");

                                friendList = new JSONArray(jsondata);
                                for (int l=0;l< friendList.length();l++){
                                    childFriendRef.child(friendList.getJSONObject(l).getString("id")).child("name").setValue(friendList.getJSONObject(l).getString("name"));
                                    childFriendRef.child(friendList.getJSONObject(l).getString("id")).child("id").setValue(friendList.getJSONObject(l).getString("id"));

                                }

                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            mProgress.dismiss();

                            Intent mainIntent = new Intent(IntroActivity.this,MainActivity.class);
                            startActivity(mainIntent);
                            finish();

                        }

                    }
                });

0 个答案:

没有答案