0

I am using Firebase in my app and I allow users to login with Facebook. I can successfully access the logged in Facebook user with Auth.auth().

The problem that I am having now is that some profile pictures gives me a "URL signature expired". I would like to re-fetch the latest profile picture URL and update the logged in user, but I am not quite sure how I can achieve this.

I know that Facebook provides an URL to get the new profile picture image: http://graph.facebook.com/<facebook-id>/picture

Or I could also alternatively use the FBSDKGraphRequest to get the latest profile picture URL:

    FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "picture"]).start(completionHandler: { _, result, error in
        guard
            error == nil,
            let result = result as? [String: Any],
            let picture = result["picture"] as? [String: Any],
            let data = picture["data"] as? [String: Any],
            let pictureURL = data["url"] as? String else {
                return
        }

        log.debug(pictureURL)
    })

But none of these solutions will update the profile picture URL when using Auth.auth().photoURL again. Any ideas on how I can update the photoURL and get the new photoURL when using Auth.auth().photoURL?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
José
  • 3,112
  • 1
  • 29
  • 42
  • 1
    https://stackoverflow.com/questions/41711409/firebase-facebook-login-photo-url-signature-expired? or https://groups.google.com/forum/#!topic/firebase-talk/61AMq2zqc-o? – Frank van Puffelen Aug 25 '17 at 14:42
  • I am not quite sure how this would be handled though. Would I need to login again when the photoURL expired? – José Aug 25 '17 at 14:47
  • 1
    That's indeed what it looks like. The photoURL is likely read from Facebook when you sign-in and from then on the cached version is returned. – Frank van Puffelen Aug 25 '17 at 15:34
  • Thanks @FrankvanPuffelen. I will see how logging in again affects the app. I could alternatively use my own custom User model that also has the profile picture URL and only update that model with the suggested solutions above in the OP. – José Aug 25 '17 at 15:43

0 Answers0