我正在尝试使用firebase为我的应用程序制作Facebook登录方法。我设置了我的Facebook应用程序和sdk。
登录到Facebook工作正常..问题是当Firebase尝试signInWithCredential
身份验证失败时。我还没有找到任何有效的解决方案。所以这是我的Logcat:
signInWithCredential:failure
com.google.firebase.FirebaseException: An internal error has occurred. [ Unsuccessful debug_token response from Facebook:{"error":{"message":"(#100) You must provide an app access token or a user access token that is an owner or developer of the app","type":"OAuthException","code":100,"fbtrace_id":"CnaYlxG66lv"}} ]
at com.google.android.gms.internal.zzdxm.zzao(Unknown Source)
at com.google.android.gms.internal.zzdwn.zza(Unknown Source)
at com.google.android.gms.internal.zzdxx.zzap(Unknown Source)
at com.google.android.gms.internal.zzdya.onFailure(Unknown Source)
at com.google.android.gms.internal.zzdxo.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:573)
这是我的代码:
Facebook按钮和CallbackManager :
mAuth = FirebaseAuth.getInstance();
mCurrentUser = mAuth.getCurrentUser();
mCallbackManager = CallbackManager.Factory.create();
mFacebook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mFacebook.setEnabled(false);
LoginManager.getInstance().logInWithReadPermissions(SignUp.this, Arrays.asList("email", "public_profile"));
LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d(TAG, "facebook:onSuccess:" + loginResult);
handleFacebookAccessToken(loginResult.getAccessToken());
}
@Override
public void onCancel() {
Log.d(TAG, "facebook:onCancel");
Toast.makeText(SignUp.this, "Facebook Login is Canceled",Toast.LENGTH_LONG).show();
// ...
}
@Override
public void onError(FacebookException error) {
Log.d(TAG, "facebook:onError", error);
Toast.makeText(SignUp.this, "Facebook Login Error",Toast.LENGTH_LONG).show();
// ...
}
});
}
});
OnActivityResult :
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mCallbackManager.onActivityResult(requestCode, resultCode, data);
}
Firebase handleFacebookAccessToken :
private void handleFacebookAccessToken(AccessToken token) {
Log.d(TAG, "handleFacebookAccessToken:" + token);
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
mAuth.signInWithCredential(credential)
.addOnCompleteListener(SignUp.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Log.d(TAG, "signInWithCredential:success");
Toast.makeText(SignUp.this,"Logged in", Toast.LENGTH_LONG).show();
} else {
Log.w(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(SignUp.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
Strings.xml :所有内容都是Facebook登录快速入门的副本
AndroidManifest :所有内容都是来自Facebook登录快速入门的副本。
Project Build.gradle :
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我认为这就是一切,如果还有别的东西指向我,我会更新我的答案,谢谢!
答案 0 :(得分:1)
尝试并更新onClick功能中的功能。我测试了下面的方法并登录。我有一个单独的firebase问题(我相信)
QTextDocument