I am not using django's default auth mechanism, my auth works like this, i pass in a user id to my api endpoint, it verifies it against an external db, and then sends an otp to the client after the verification of the otp i will return the jwt token to authenticate with other api endpoints.
from datetime import datetime
from calendar import timegm
from rest_framework_jwt.settings import api_settings
def jwt_payload_handler(client_id):
""" Custom payload handler
Token encrypts the dictionary returned by this function, and can be decoded by rest_framework_jwt.utils.jwt_decode_handler
"""
return {
'user_id': client_id,
'exp': datetime.utcnow() + api_settings.JWT_EXPIRATION_DELTA,
'orig_iat': timegm(
datetime.utcnow().utctimetuple()
)
}
def jwt_response_payload_handler(token, user=None, request=None):
""" Custom response payload handler.
This function controlls the custom payload after login or token refresh. This data is returned through the web API.
"""
return {
'token': token
}
Can someone please point out what is happening here and what can i do to make it work, How can i override the default authentication so that it works without the user model in place and it validates against (say a client_id which exists in my external remote database) ?
I am getting an error when i try to refresh the token or verify it on the endpoint.
I did a print of my payload and here is what I get
I am not using django's default auth mechanism, my auth works like this, i pass in a user id to my api endpoint, it verifies it against an external db, and then sends an otp to the client after the verification of the otp i will return the jwt token to authenticate with other api endpoints.
Here is the custom function i implemented based on what was suggested over here https://github.com/GetBlimp/django-rest-framework-jwt/issues/145
Can someone please point out what is happening here and what can i do to make it work, How can i override the default authentication so that it works without the user model in place and it validates against (say a client_id which exists in my external remote database) ?