title: Return Username and ID with Django Rest Framework Simple JWT TokenRefresh
body: <p>I'm using Django Rest Framework and django-rest-framework-simplejwt for authentication.  The data being sent is being consumed by react.</p>
  
  <p>So far I've been able to subclass the <code>TokenObtainPairSerializer</code> to return both the username and ID when logging in  / getting a new token.</p>
  
  <pre><code>class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
      def validate(self, attrs):
          data = super(MyTokenObtainPairSerializer, self).validate(attrs)
  
          data.update({'user': self.user.username})
          data.update({'id': self.user.id})
  
          return data
  </code></pre>
  
  <p>I'm trying to have a users username and id returned when the token is refreshed as well.  This, however, does not work:</p>
  
  <pre><code>class MyTokenRefreshSerializer(TokenRefreshSerializer):
  
      def validate(self, attrs):
          data = super(MyTokenRefreshSerializer, self).validate(attrs)
          user = self.context['request'].user
          data.update({'user': user.username})
          data.update({'id': user.id})
  
          return data  
  </code></pre>
  
  <p>Here, the username is always returned as an empty string and the ID is always returned as null.</p>
  
  <p>I've tried many different ways, including trying to update this information in the view itself, but can't seem to get it to work.  I've noticed that <code>TokenRefreshSerializer</code> subclasses <code>serializers.Serializer</code> while TokenObtainPairSerializer subclasses <code>TokenObtainSerializer</code> which itself authenticates a user using Django authentication.  This appears to require a password (like when a user logs in) but obviously that wouldn't be provided when simply refreshing a token.</p>
  
  <p>My question is, how can I return the username and id (or any arbitrary information) about the current user when the token is refreshed?</p>
  
  <p>The follow-on question would be, is it more practical to simply save that information to localStorage on the front end when the user first logs in and have the state re-populate that data on each subsequent visit (until the user logs out, or the refresh token is no longer valid)?</p>
  
  <p><strong>Please Note</strong>: This is not a repost of similar questions such as <a href="https://stackoverflow.com/questions/53480770/how-to-return-custom-data-with-access-and-refresh-tokens-to-identify-users-in-dj">this one</a>, because I am targeting the REFRESHING of tokens.  The initial <code>TokenObtainPairView</code> was straightforward to subclass and implement.</p>