python - Store more than default information in django-rest-framework-jwt -


i using django version 1.8 , authentication django-rest-framework-jwt. after authentication, our application return front-end information:

from rest_framework_jwt.settings import api_settings rest_framework.response import response django.contrib.auth.models import user   jwt_payload_handler = api_settings.jwt_payload_handler jwt_encode_handler = api_settings.jwt_encode_handler  user.profile_picture = "test_profile_picture.jpg" #user django.contrib.auth.models.user object payload = jwt_payload_handler(user)  token = jwt_encode_handler(payload)   jwt_login_response = {         "token": token  }  return response(jwt_login_response,status=status.http_200_ok) 

in front-end, decode by

import jwtdecode 'jwt-decode'; var decodedtoken = jwtdecode(token); 

but @ moment decodedtoken contains value seem default django-rest-framework-jwt

object {username: "test", user_id: 9, email: "test@gmail.com", exp: 1454754137} 

i want store more information in jwt profile_picture don't know how. want find solution problem.

you can override payload attached token jwt_payload_handler setting.

the default implementation includes username, user_id, email, , exp (expiration time), you've noticed. can find default implementation on github.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -