Información de Facebook no se muestra

Intento get la información del usuario con este código pero no se muestra en la actividad. La image del perfil y el nombre no crean un nuevo usuario en la base.

¿Qué me estoy perdiendo? ¿Alguien ha codificado esto usando Kotlin?

private fun handleFacebookAccessToken(token: AccessToken) { Log.d(TAG, "handleFacebookAccessToken:" + token) val cnetworkingential = FacebookAuthProvider.getCnetworkingential(token.token) App.currentAuth.signInWithCnetworkingential(cnetworkingential) .addOnCompleteListener(this) { Log.d(TAG, "signInWithCnetworkingential:success") } .addOnSuccessListener(this) { authResult -> if (authResult != null) { val firebaseUser = authResult.user if (App.database_table_users.child(firebaseUser.uid) == null) { var facebookId = "" firebaseUser.providerData .filter { it.providerId == FacebookAuthProvider.PROVIDER_ID } .forEach { facebookId = it.uid } val photoUrl = "https://graph.facebook.com/$facebookId/picture?width=1024&height=1024" App.database_table_users.child(firebaseUser.uid).setValue( User(firebaseUser.uid, firebaseUser.email.orEmpty(), firebaseUser.displayName.orEmpty(), photoUrl, false ) ) } } } .addOnFailureListener(this) { ex -> if (ex is FirebaseAuthUserCollisionException) { LoginManager.getInstance().logOut() val ad = AlertDialog.Builder(this@LoginActivity) ad.setMessage(getString(R.string.auth_user_collision)) ad.setPositiveButton(getString(R.string.ok), null) ad.show() } else { ex.printStackTrace() } } } 

Debes usar FirebaseAuth.getInstance () en lugar de App.currentAuth. Por ejemplo;

 val mAuth = FirebaseAuth.getInstance() val cnetworkingential = FacebookAuthProvider.getCnetworkingential(token) mAuth.signInWithCnetworkingential(cnetworkingential) .addOnCompleteListener(this) { task -> if (task.isSuccessful) { val user = mAuth.currentUser } else { task.exception?.printStackTrace() } } 

Prueba esto, es trabajo para mí

  private fun loginWithFaceBook() { LoginManager.getInstance().registerCallback(callbackManager, facebookCallBack) LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile","email")) } private val facebookCallBack = object : FacebookCallback<LoginResult> { override fun onSuccess(result: LoginResult?) { val graphRequest = GraphRequest.newMeRequest(result?.accessToken) { _, response -> val graphObject = response.jsonObject val id = if(graphObject.has("id")) graphObject.getString("id") else null val email = if(graphObject.has("email")) graphObject.getString("email") else null val firstName = if(graphObject.has("first_name")) graphObject.getString("first_name") else null val lastName = if(graphObject.has("last_name")) graphObject.getString("last_name") else null val photoUrl = if(graphObject.has("picture")) { val picture : JSONObject = graphObject.getJSONObject("picture") if(picture.has("data") && picture.has("url") && picture.getString("url").isNotBlank()) { picture.getString("url") } else null } else val bundle = Bundle() bundle.putString("fields", "id,first_name,last_name,name,picture,email,gender,birthday,link") graphRequest.parameters = bundle graphRequest.executeAsync() } override fun onError(error: FacebookException) { when{ error.message != null -> showSnackbar(error.message.toString()) } } override fun onCancel() { } }