title: How to extract profile_pic of a user when they are signing in from Google
body: <p>I'm making a django website, I have 2 login methods. One is the default email password login and another is by logging in from Google.</p>
  <p>What I want is when the user logs in from google django should automatically fetch the profile_pic of that user and save it in my user model.</p>
  <p>Here's my <code>models.py</code> for <code>accounts</code> app</p>
  <pre><code>from django.db import models
  from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager, Group
  
  
  # Custom User Manager
  class CustomUserManager(BaseUserManager):
      def _create_user(self, email, password, first_name, last_name=None, **extra_fields):
          if (not email):
              raise ValueError(&quot;Email Must Be Provided&quot;)
          if (not password):
              raise ValueError(&quot;Password is not Provided&quot;)
  
          user = self.model(
              email=self.normalize_email(email),
              first_name=first_name,
              last_name=last_name,
              **extra_fields
          )
  
          user.set_password(password)
          user.save(using=self._db)
  
          return user
  
      def create_user(self, email, password, first_name, last_name=None, **extra_fields):
          extra_fields.setdefault('is_staff', False)
          extra_fields.setdefault('is_active', False)
          extra_fields.setdefault('is_superuser', False)
          return self._create_user(email, password, first_name, last_name, **extra_fields)
  
      def create_user_with_groups(self, email, password, first_name, last_name=None, **extra_fields):
          extra_fields.setdefault('is_staff', True)
          extra_fields.setdefault('is_active', True)
          extra_fields.setdefault('is_superuser', False)
  
          user = self._create_user(email, password, first_name, last_name)
          group = Group.objects.get(name='Content Writer')
  
          user.groups.add(group)
          print(user.groups)
          return user
  
      def create_superuser(self, email, password, first_name, last_name=None, **extra_fields):
          extra_fields.setdefault('is_staff', True)
          extra_fields.setdefault('is_active', True)
          extra_fields.setdefault('is_superuser', True)
  
          if extra_fields.get('is_staff') is not True:
              raise ValueError('Superuser must have is_staff=True.')
          if extra_fields.get('is_superuser') is not True:
              raise ValueError('Superuser must have is_superuser=True.')
  
          return self._create_user(email, password, first_name, last_name, **extra_fields)
  
  
  # Custom user Model
  class User(AbstractBaseUser, PermissionsMixin):
      email = models.EmailField(db_index=True, unique=True, max_length=254)
      first_name = models.CharField(max_length=255)
      last_name = models.CharField(max_length=255, null=True, blank=True)
      mobile = models.CharField(max_length=50, null=True, blank=True)
      address = models.CharField(max_length=250, null=True, blank=True)
      profile_pic = models.ImageField(null=True, blank=True, upload_to='profile_pics/users',
                                      default='default_profile_pic.svg')
  
      is_staff = models.BooleanField(default=True)
      is_active = models.BooleanField(default=True)
      is_superuser = models.BooleanField(default=False)
  
      objects = CustomUserManager()
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = ['first_name']
  
      class Meta:
          verbose_name = 'User'
          verbose_name_plural = 'Users'
  </code></pre>
  <p>Is there any way of achieving this? If there is, then it would be preferred to have a solution using <code>SCOPES</code></p>
  <p>Here is my <code>settings.py</code> file for <code>SCOPES</code></p>
  <pre><code>...
  SOCIALACCOUNT_ADAPTER = 'MyApp.adapter.MySocialAccountAdapter'
  SOCIALACCOUNT_QUERY_EMAIL = ACCOUNT_EMAIL_REQUIRED
  SOCIALACCOUNT_LOGIN_ON_GET = True
  SOCIALACCOUNT_AUTO_SIGNUP = True
  SOCIALACCOUNT_PROVIDERS = {
      'google': {
          'SCOPE': [
              'profile',
              'email',
          ],
          'AUTH_PARAMS': {
              'access_type': 'online',
          }
      }
  }
  ...
  </code></pre>
  <p><strong>EDIT:</strong> I found the 'picture' field in the extra data of my social account profile in admin panel. How do I make use of that value in 'picture' field in the 'profile_pic' field of my User model. What function should I write to overwrite the default functionality.</p>
  <p><a href="https://i.stack.imgur.com/RrEiS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RrEiS.png" alt="enter image description here" /></a></p>