Android Question [FirebaseAuth] CurrentUser.PhotoUrl return 404.

zolive33

Active Member
Licensed User
Longtime User
Hello,

Since few days, the Method PhotoUrl returns an error code 404.

Code example :
B4X:
        Dim FBAuth As FirebaseAuth
        FBAuth.Initialize("")
        wbPhoto.Color=Colors.Transparent
        wbPhoto.LoadHtml("<html><body><img style=""position:absolute; border-radius:5px; left:0px; top:0px; width:100%; height:100%;"" src='" & FBAuth.CurrentUser.PhotoUrl & "'/></body></html>")

In my example, FBAuth.CurrentUser.PhotoUrl returns https://lh3.googleusercontent.com/-...V0G9pQ0gQXSwzTlAUDMJfHiaATzjw/s96-c/photo.jpg

Is it a Firebase bug?

Thank you for your help.
 

DonManfred

Expert
Licensed User
Longtime User
Is it a Firebase bug?
Open the url you posted.... The image is not found. The error 404 raises....
The image is not available on this url
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
Open the url you posted.... The image is not found. The error 404 raises....
The image is not available on this url

Yes, but it is not normal that this url be returned by Firebase. This problem suddenly occurred without modification of code.
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
It sounds like a firebase issue.

hi Erel,

I think it's not a FireBase issue : When I change user name or Photo in Google profile, the new values are not updated automatically in app.
I think we should use the reload method (or updateProfile). but I don't know how.

perhaps it requires an evolution of the FirebaseAuth library.
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
Thanks Erel, but it didn't work.

Here is what I did:
- On the Firebase console: deleting the user account
- On android device :
- Uninstalling the application
- re-installation
- re-authentication​

I think there is another solution. I look for....
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
There is a difference between Firebase and Google data.
Once initialized, the Firebase user-account is no longer updated.

B4X:
Dim jo As JavaObject = Starter.auth.CurrentUser
Dim providerData As List = jo.RunMethod("getProviderData", Null)

'UserInfo
For Each item In providerData
    Dim jo2 As JavaObject = item
    Log("providerId : " & jo2.RunMethod("getProviderId", Null))
    Log("photoUrl : " & jo2.RunMethod("getPhotoUrl", Null))
Next

providerId : firebase
photoUrl : https://lh5.googleusercontent.com/-...V0_th2s40bwLHWz6f71sMMDjnRWXg/s96-c/photo.jpg
providerId : google.com
photoUrl : https://lh5.googleusercontent.com/-...A1Leogv1QyzmVxrfcEb1fhxMhwnug/s96-c/photo.jpg
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Just checked one of my apps. I retrive the photo URL after signin with the user's Google account.

Please update your google-services.json (= download it again).

My code:

B4X:
Sub GoogleSignIn

    Auth.Initialize("auth")
    If Auth.CurrentUser.IsInitialized = False Then
        Auth.SignInWithGoogle
    End If
   
End Sub

B4X:
Sub Auth_SignedIn (User As FirebaseUser)
  
    Log("Name: " & User.DisplayName)
    Log("Mail: " & User.Email)
    Log("Photo: " & User.PhotoUrl)
    Log("Token: " & User.Uid)
  
    GoogleName=User.DisplayName
    GoogleMail= User.Email
    GoogleUserToken= User.Uid
    GooglePhotoUrl = User.PhotoUrl
      
End Sub

and then just

B4X:
Dim IconJob As HttpJob
    IconJob.Initialize("DownloadUserIcon", Me)
    IconJob.Download(User.PhotoUrl)

in JobDone

B4X:
Dim BM As Bitmap
                 BM.Initialize2(Job.GetInputStream)
                 ...

URL is ok, no problems here.
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
Hi. Here is a small example project.

1 - I sign with user "[email protected]".
Name displayed : Pierre Apptest
screenshot-2017-09-18_21.57.27.476.png screenshot-2017-09-18_22.12.47.426.png
2 - I sign out
3 - On Google profile, i change photo and given name
4 - After about an hour, I sign with the same user
screenshot-2017-09-18_23.08.26.823.png screenshot-2017-09-18_23.08.35.362.png

:(
 

Attachments

  • FirebaseAuth.zip
    12.7 KB · Views: 211
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I'm not able to change my photo and try. Could you change your code to retrieve the url to that of my post #10?

Does this happen only when you CHANGE the picture via Google console? Please check if you synchronize APP data (Google account).
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
Hi KMatie.

Tonight urlPhoto is up to date (on Firebase user's profile, like on google profile).

Look no further, a developer colleague explained to me: There are some bugs on Firebase (Erel is right! post #5)
1 - if the original profile photo url returns a 404. Firebase doesn't seem to update user profile (bug). Otherwise Firebase takes 12 or 24 hours to update its data.
2 - the "DisplayName" is never updated (bug?).

Solution: He advises me to use Google profile data.
It is possible to force update the user profile information by using "updateProfile" method. https://firebase.google.com/docs/re...oogle.firebase.auth.UserProfileChangeRequest)
 
Upvote 0
Top