How to customize the payload section of the JWT response
<p>What do I need to do to customize the <code>url(r'^auth/login/', obtain_jwt_token)</code> view to allow me to add data to the JWT token</p>

<p>I have a django-rest-framework API that is used by independent web applications. What I want is to return to the web app the logged in user's role and permissions together with what djangorestframework-jwt already returns.</p>

<p>I already have the roles in a python dictionary but I can't figure out what is required to override the default payload. </p>

<p>user_payload = {'user': user, 'roles': roles}</p>

<p>I thought it was as simple as replacing the 'user' in <code>payload = jwt_payload_handler(user)</code> with my user_payload but then am getting serializer errors. Is there a cleaner/easier way to do it? </p>

<p>djangorestframework==3.4.7, djangorestframework-jwt==1.8.0</p>