Open laranicolas opened 8 years ago
Looking at the default payload creating method, it looks like it expects 'identity' instead of 'id' for the key. That might be the problem.
Alternatively, perhaps checkout flask-jwt-extended. It's designed to make a few things llke this easier to do: http://flask-jwt-extended.readthedocs.io/en/latest/add_custom_data_claims.html (I am the author of that extension).
Hope this helps!
Hey thanks for answer!
But I never see on the console the string print YEAH
, could be decorator not be working?
Other things are working correctly, but I want to overwrite the payload.
jwt = JWT(app, authenticate, identity)
@jwt.jwt_payload_callback
def make_payload(u):
print "YEAH"
print "YEAH"
iat = datetime.utcnow()
exp = iat + timedelta(seconds=60)
nbf = iat + timedelta(seconds=0)
return {'iat': iat, 'exp': exp, 'nbf': nbf, 'id': u.id, 'role': u.role}
I think you need to change it from jwt_payload_callback to jwt_payload_handler.
On Oct 15, 2016 11:20 AM, "Nicolás Lara" notifications@github.com wrote:
Hey thanks for answer!
But I never see on the console the string print YEAH, could be decorator not be working?
Other things are working correctly, but I want to overwrite the payload.
jwt = JWT(app, authenticate, identity)
@jwt.jwt_payload_callback def make_payload(u): print "YEAH" print "YEAH" iat = datetime.utcnow() exp = iat + timedelta(seconds=60) nbf = iat + timedelta(seconds=0) return {'iat': iat, 'exp': exp, 'nbf': nbf, 'id': u.id, 'role': u.role}
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mattupstate/flask-jwt/issues/102#issuecomment-253997833, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOlVfSCqlfGoPN2BENniLiM-5FqGMexks5q0QttgaJpZM4KXsxs .
Sorry, yes I'm using @jwt.jwt_payload_handler
, but also is not working, any idea?
I dont, sorry. It's been a while since I used this library, and with all the open issues and pull requests it looks like it isn't being maintained at the moment either, which is why I made the flask_jwt_extended library. If you end up trying the flask_jwt_extended library and had issues there I would be able to help further.
Best of luck getting this working, the source code for this library isn't very big, so perhaps looking though it you could find your answer.
Thanks anyway for the predisposition to answer. I already see the code, but for the moment I didn't see a decorator for jwt_payload_hanlder, I will continue debugging if couldn't I will try to use your extension!
@vimalloc I will remove flask-jwt use your extension!
I hope it helps you out :) It's still a relatively new extension, so if you run into any oddities, issues, or missing features, please let me know.
I just found an issue, I will write you on flask_jwt_extended github.
Hey, I'm trying to overwrite the default payload_callback but I can't, what I'm doing wrong?
I would expect to see in payload next result:
{'iat': iat, 'exp': exp, 'nbf': nbf, 'id': u.id, 'role': u.role}