允许 Firebase 用户也使用 Twitter 进行身份验证

时间:2021-05-19 16:48:18

标签: android firebase

当用户已经使用他们的电子邮件登录时,我也想获取他们的 Twitter 信息。

我试过这样做..

OAuthProvider.Builder provider = OAuthProvider.newBuilder("twitter.com");
        FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
        firebaseAuth
                .startActivityForSignInWithProvider(/* activity= */ this, provider.build())
                .addOnSuccessListener(
                        new OnSuccessListener<AuthResult>() {
                            @Override
                            public void onSuccess(AuthResult authResult) { 
                       System.out.println(authResult.getAdditionalUserInfo().getUsername());
                            }
                        })
                .addOnFailureListener(
                        new OnFailureListener() {
                            @Override
                            public void onFailure(@NonNull Exception e) {
                                // Handle failure.
                                e.printStackTrace();
                            }
                        });

我收到此错误,但不知道为什么。

2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err: com.google.firebase.auth.FirebaseAuthException: There was an error while trying to get your package certificate hash.
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at com.google.android.gms.internal.firebase-auth-api.zztt.zza(com.google.firebase:firebase-auth@@20.0.3:26)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at com.google.firebase.auth.internal.zzav.onReceive(com.google.firebase:firebase-auth@@20.0.3:19)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:313)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:121)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at android.os.Looper.loop(Looper.java:214)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7073)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
2021-05-19 12:41:59.753 30765-30765/app.thecsn W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

0 个答案:

没有答案