Simon
Simon

Reputation: 797

Getting another user's PhotoURL in Firebase

I'm using the Firebase 3 SDK with AngularFire.

I can use the AngularFire code below to get the photoURL of the currently authenticated user:

$firebaseAuth().$getAuth().photoURL;

But, given the UID of another user, how do I get that user's photo, so I can display it on the page?

I'm assuming any user can read the PhotoURL of any other user (that makes sense since the PhotoURL is to your public picture) But I can't find out how to look it up for arbitrary users. Am I being stupid and missing something obvious?

Upvotes: 0

Views: 1257

Answers (1)

Caleb
Caleb

Reputation: 2298

Firebase alone won't allow you to access other user's photoUrl. Depending on the provider, you can use their respective APIs to get other user's photos.

For example, if your provider was Google OAuth2, you can ask for additional scope of contacts, calendar, etc (a lot of them have user/photo meta data that gets returned) and the make API calls with the user's google access token to fetch more info.

An alternative solution might be to cache the photos of people who have logged into your service. So basically you would be saving all the photoURLs of people who have logged in. There several downsides to this approach though.

  1. You don't have photos for people who have not logged in yet.
  2. This might be against the provider's user privacy policy.
  3. The photo can be outdated unless you are proactive about syncing the photoURL.

Upvotes: 2

Related Questions