Not able to fetch Facebook profile image using Firebase Authentication-Kotlin
1

I am working on a project in which I have integrated Facebook login using Firebase authentication. I am fetching the public profile picture. However my code is not able to do this task. Please try to fix this.

Here is the small part of the code I used

private fun handleFacebookAccessToken(token: AccessToken) {
        val credential = FacebookAuthProvider.getCredential(token.token)
        auth.signInWithCredential(credential)
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    val user = auth.currentUser
                    val photoUrl = "${user.photoUrl}?access_token=${token.token}"

Here I did not get any image

private fun handleFacebookAccessToken(token: AccessToken) {
        val credential = FacebookAuthProvider.getCredential(token.token)
        auth.signInWithCredential(credential)
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    val user = auth.currentUser
                    val photoUrl = user.photoUrl.toString()

When I used the following code, I am getting the default Facebook profile photo:

Rishabbh
Asked about 6 months ago