question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to access payload's iss on 1.0.0 on validateJwt() ?

See original GitHub issue

Hello, im new and not used to this library, and im trying to port from djwt 0.9.0 to 1.0.0.

On 0.9.0 i could use validateJwt to get the payload and therefore the iss data stored there as the following:

const data = await validateJwt(
    jwt,
    secret,
    { isThrowing: false},
  );

console.log(data.payload.iss);

but now i can’t, and i can’t find any updated example on the docs.

How can i access the iss data from a decripted jwt token on 1.0.0? Sorry for any inconvenience.

Best regards!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
marcomaiselcommented, Jul 16, 2020

Hi @Frenzoid It seems like the validateJwt function had breaking changes rom 0.9.0 to 1.0.0.

Instead of { isThrowing: false} you now need to specify the algorithm { algorithm: "HS256" }

As the documentation states “The function validateJwt returns a promise. This promise resolves to an object with a union type where the boolean property isValid serves as discriminant.” This means you need to check if the JWT is valid to get access to the payload.

const data = await validateJwt(
    jwt,
    secret,
    { algorithm: "HS256" },
  );

if (data.isValid) {
    console.log(data.payload.iss);
}
1reaction
marcomaiselcommented, Aug 31, 2020

Have a look at issue #25. The suggested solution should fix your problem, too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VerifyJWT policy | Apigee Edge
The JSON-parsable value of a header in the payload. One variable is set for every header in the payload. While you can also...
Read more >
Spring Boot security expressions for Auth0 JWT
First issue could be solved by using services like Auth0, they provide user management, access control and authentication libraries for websites ...
Read more >
Validate JWT - IBM
Use the Validate JWT security policy to enable the validation of a JSON Web Token (JWT) in a request before allowing access to...
Read more >
Using JWT RBAC - Quarkus
Here we inject the JAX-RS SecurityContext to inspect the security state of the call and use a getResponseString() function to populate a response...
Read more >
PyJWT 1.0.0 - PyPI
You can still get the payload by setting the verify argument to False. ... in both jwt.encode() and jwt.decode() ("secret" in the examples)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found