'How to add user photo to JWT auth tokens in django?

Is it posible to have an image information added to jwt auth token like any other user data? If it s posible, someone please can you help with the solution I'll highly wholeheartedly appreciate it..

Here's how I added the other user data to the jwt token..

class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
@class method

def get_token(cls, user):

token = super().get_token(user)

token['username'] = user.username

token['occupation'] = user.profile.occupation

token['biography'] = user.profile.biography

I hope this helps, and please if you need any file to help better understand the situation, I'll definitely be glad to submit it.. Thanks In advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source