Gabriel Donada
Gabriel Donada

Reputation: 449

Unable to get image from Google User profile

In my react web app, sometimes it doesn't load the image from the user profile. I'm using react. It normally works, but sometimes it doesn't.

Here is the error that browser shows:

Failed to load resource: the server responded with a status of 403 ()

enter image description here

Here is my code:

async function singIngWithGoogle(){
    const provider = new firebase.auth.GoogleAuthProvider();
        
    const loginResult = await auth.signInWithPopup(provider);
      
        if(loginResult.user){
          const { displayName, photoURL, uid, email } = loginResult.user;
          
          if( !displayName || !photoURL ){
            throw new Error('Seu usuário Google não possui nome ou foto.');
          }

          setUser({
            id: uid,
            name: displayName,
            avatar: photoURL ?? {noUserImg},
            userEmail: email ?? ''
          })

        }
  }

Upvotes: 1

Views: 1327

Answers (1)

Hassan hmc
Hassan hmc

Reputation: 91

Use this attribute in your image tag in react js. referrerpolicy="no-referrer"

<img src="" referrerpolicy="no-referrer" />

Upvotes: 9

Related Questions