Code Monkey home page Code Monkey logo

Comments (5)

sureshjoshi avatar sureshjoshi commented on August 26, 2024

Hey, the JWT is base64 encoded, so you'd need to use a base64 decode to get the information stored in the first two parts of the JWT (the 3rd part is the secure sign).

So, for your example (https://www.base64decode.org/):
The first part of the JWT gives ('part' being the data up to the first period)
{"alg":"HS256","exp":1432115032,"iat":1432115002}

And the second part gives (between first period and second period)
{"user_id":1}

Here is a good discussion of JWT structure: https://developer.atlassian.com/static/connect/docs/latest/concepts/understanding-jwt.html

So, your JWT helper needs to do a base64 decode, and then parse JSON structures to give you what you want.

Please note that due to using itsdangerous under the hood, there are a few quirks where data is stored, see: #40

Also, to make your life easier, consider using Satellizer (https://github.com/sahat/satellizer) - handles a lot of the grunt stuff behind the scenes.

from flask-jwt.

aabmass avatar aabmass commented on August 26, 2024

@hussaintamboli was definitely having the same problem as issue #40. BTW, he isn't trying to decode the JWT himself; jwtHelper is from angular-jwt (an angularjs module). The issue is that jwtHelper looks for the exp field in the payload, not in the header where flask-jwt is putting it.

from flask-jwt.

mattupstate avatar mattupstate commented on August 26, 2024

Care to upgrade and see how things go?

from flask-jwt.

hussaintamboli avatar hussaintamboli commented on August 26, 2024

Sure. I'll do that and let you know.

from flask-jwt.

hussaintamboli avatar hussaintamboli commented on August 26, 2024

Apologies :(

Haven't found time to check this yet.

from flask-jwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.