admin管理员组

文章数量:1326134

I am using Firebase / Google sign-in authentication to log users in my app. The authentication works perfectly with Gmail account - however, with the accounts of my client, which has a business Gmail account ([email protected]), the authentication works but the user profile picture is not shared (the User object is returned with a default picture, like this one : .jpg ).

For information, I am using the very standard signInWithPopup method :

var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider)      
  .then((credential) =>  {
    var authState = credential.user
    updateUserData()  // Updating user's data })
  .catch(error => console.log(error))

So I tried to get around this by finding the profile photos directly on the net, instead of getting it from the authentication, by using id based url, for example like this :

/?alt=json

But the json also returns a default photo for the email adresses with the business account, so this makes me assume there must be some specific privacy settings for this business account which prevent the photos from being shared.

Does any one had this problem already, or has any idea on :

  • the settings to be changed on gmail business accounts to enable profile photo sharing?
  • if it is possible to make a consent screen, to get the consent of the user to share his basic profile infos with the app (I know the consent screen has been removed recently by Google when the app requires only basic profile informations -name, email, photo, ..-) ?
  • a more 'hacky' way to get the photos from the net ?
  • any other suggestion ?

I am using Firebase / Google sign-in authentication to log users in my app. The authentication works perfectly with Gmail account - however, with the accounts of my client, which has a business Gmail account ([email protected]), the authentication works but the user profile picture is not shared (the User object is returned with a default picture, like this one : https://lh3.googleusercontent./-9Me77eEe8m0/AAAAAAAAAAI/AAAAAAAAAAA/0uO0KAv-PMQ/photo.jpg ).

For information, I am using the very standard signInWithPopup method :

var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider)      
  .then((credential) =>  {
    var authState = credential.user
    updateUserData()  // Updating user's data })
  .catch(error => console.log(error))

So I tried to get around this by finding the profile photos directly on the net, instead of getting it from the authentication, by using id based url, for example like this :

http://picasaweb.google./data/entry/api/user/?alt=json

But the json also returns a default photo for the email adresses with the business account, so this makes me assume there must be some specific privacy settings for this business account which prevent the photos from being shared.

Does any one had this problem already, or has any idea on :

  • the settings to be changed on gmail business accounts to enable profile photo sharing?
  • if it is possible to make a consent screen, to get the consent of the user to share his basic profile infos with the app (I know the consent screen has been removed recently by Google when the app requires only basic profile informations -name, email, photo, ..-) ?
  • a more 'hacky' way to get the photos from the net ?
  • any other suggestion ?
Share Improve this question edited Jan 17, 2018 at 11:24 halfer 20.3k19 gold badges109 silver badges202 bronze badges asked Jan 13, 2018 at 13:29 Elise PatrikainenElise Patrikainen 3332 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

I've been stuck on this same issue for days. This is how I managed to get the correct photo url!

var user = firebase.auth().currentUser;

if (user != null) {
  user.providerData.forEach(profile => {
    console.log(profile.photoURL);
  }); //this will give you all the urls once there is user data
}

Most likely you are loading the dummy url while firebase is still fetching all the user info. You just need to add a check to make sure there is user data before trying to get the urls. I am using my business account too.

本文标签: