title: How to provide user types while registering as a user using google in Django rest framework
body: <p>I have a customeuser model which inherits from AbstractUser. I have also used sign-up using google feature. But now later in my project, I have to add user types. For eg user can be owner,manager and staff and they have their own privileges.</p>
  <p>My model:</p>
  <pre><code>ROLE = (('owner','OWNER'),('manager','MANAGER'),('staff','STAFF'))
  class User(AbstractUser):   
  
      SOCIAL_AUTH_PROVIDERS = (
          (&quot;GOOGLE&quot;, (&quot;GOOGLE&quot;)),
          (&quot;FACEBOOK&quot;, (&quot;FACEBOOK&quot;)),
          (&quot;TWITTER&quot;, (&quot;TWITTER&quot;)),
      )
  
      name = CharField(_(&quot;Name of User&quot;), blank=True, max_length=255)
      email = EmailField(_(&quot;Email Address&quot;), unique=True)
      mobile = CharField(
          _(&quot;Mobile Number&quot;), max_length=16, unique=True, blank=True, null=True
      )
      email_verified = BooleanField(default=False)
      social_auth = CharField(
          choices=SOCIAL_AUTH_PROVIDERS,
          max_length=100,
          blank=True,
          null=True,
              )
      role = models.CharField(max_length=15, choices=ROLE, default='staff') #added this field later
      first_name = None  
      last_name = None  
      username = None  
  
      USERNAME_FIELD = &quot;email&quot;
      REQUIRED_FIELDS = []
  
      objects = CustomUserManager() 
  </code></pre>
  <p>Here I migrated a new field role to the user model because I needed it because of business requirements.</p>
  <p>The change in my serializer will be like this.</p>
  <pre><code>class UserRegisterationSerializer(serializers.ModelSerializer):
      def validate(self, data):
          email = data[&quot;email&quot;]
          password = data.get(&quot;password&quot;)
          role = data[&quot;role&quot;] #added this part
          mesg = &quot;This email has been already registered.&quot;
          if User.objects.filter(email=email).exists():
              raise serializers.ValidationError({&quot;email&quot;: mesg})
          if password:
              user = User(email=email,role=role) #added role here too
              try:
                  validate_password(password=password, user=user)
              except Exception as e:
                  raise serializers.ValidationError({&quot;password&quot;: e.messages})
          return data
  </code></pre>
  <p>Here while signing up from regular email and password, we can do it easily as shown above. I just get role from the data and use it to create a user with the email and role. The problem arises when we try to register using google sign up.</p>
  <p>My Google view:</p>
  <pre><code>class GoogleSocialAuthView(GenericAPIView):
  
      serializer_class = GoogleSocialAuthSerializer
      permission_classes = ()
  
      def post(self, request):
          serializer = self.serializer_class(
              data=request.data, context={&quot;request&quot;: request}
          )
          serializer.is_valid(raise_exception=True)
          return Response(serializer.validated_data, status=status.HTTP_200_OK)
  </code></pre>
  <p>My Google serializer:</p>
  <pre><code>class GoogleSocialAuthSerializer(serializers.Serializer):
      id_token = serializers.CharField()
  
      @classmethod
      def get_token(cls, user):
          return RefreshToken.for_user(user)
  
      def get_user_details(self, user):
  
          refresh = self.get_token(user)
          personal_info_added = bool(user.mobile)
          course_info_added = (
              StudentLevel.objects.exclude(subjects__isnull=True)
              .filter(student__user_id=user.pk)
              .exists()
          )
          response = {
              &quot;personal_info_added&quot;: personal_info_added,
              &quot;course_info_added&quot;: course_info_added,
              &quot;refresh&quot;: str(refresh),
              &quot;access&quot;: str(refresh.access_token),
          }
          return response
  
      def validate(self, data):
          id_token = data.pop(&quot;id_token&quot;)
          user_data = Google.validate(id_token)
          try:
              user_data[&quot;sub&quot;]
          except Exception:
              raise serializers.ValidationError(
                  {&quot;id_token&quot;: [&quot;The token is invalid or expired. Please login again.&quot;]}
              )
          if user_data[&quot;aud&quot;] != SOCIAL_AUTH_GOOGLE_OAUTH2_KEY:
  
              raise AuthenticationFailed(&quot;Invalid Google oauth key&quot;)
  
          email = user_data[&quot;email&quot;]
          name = user_data[&quot;name&quot;]
          social_auth_provider = &quot;GOOGLE&quot;
  
          user_data = User.objects.filter(email=email)
  
          if user_data.exists():
              user_details = self.get_user_details(user_data.first())
              return user_details
          else:
              user = User.objects.create(
                  email=email, name=name, social_auth=social_auth_provider
              )
              user.email_verified = True
              user.save()            
              user_details = self.get_user_details(user)
              return user_details
  </code></pre>
  <p>So, is there any way we can create user by assigning the roles beforehand ?? For eg signup as a manager or as a owner using google signup. If yes, then what changes that needs to be done in the google serializer??</p>