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.

AccessTokenPayload is null

See original GitHub issue

AccessTokenPayload is null after successful authentication.

I see that access token and id token are retrieved successfully but accesstokenpayload is null.

I noticed extractAccessTokenPayload method will return null if token contains 2 dots. Valid JWT tokens actually must contain 2 dots in order to be valid header.body.signature. Is this a bug or intentional?

const extractAccessTokenPayload = tokens => {
    if(tokens.accessTokenPayload)
    {
        return tokens.accessTokenPayload;
    }
    const accessToken = tokens.accessToken;
    try{
        if (!accessToken || countLetter(accessToken,'.') === 2) {
            return null;
        }
        return JSON.parse(atob(accessToken.split('.')[1]));
    } catch (e) {
        console.warn(e);
    }
    return null;
};

Also useOidcUser() hook says that user is not authenticated. Is this because of the same issue?

Version I am using is 5.4.2

Thank you

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
guillaume-chervetcommented, May 25, 2022

I understood, it shoulb be countLetter(accessToken,‘.’) != 2 instead of countLetter(accessToken,‘.’) === 2

I will make a pr from my phone :p

0reactions
guillaume-chervetcommented, May 30, 2022

Thank you for the feedback. I close the pullrequest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty payload in access_token - Auth0 Community
I created a new Application and API while following Auth0 tutorials and tokens requested from my Angular web application come with no payload...
Read more >
TypeError: Cannot read property 'payload' of null #15 - GitHub
Looking for some help here - I have a simple Node/Express app which is validating a token: exports.validate = function(req, res) {
Read more >
my function return null when I initiate value correctly(node.js ...
What I was trying to is 'pass different token passport's jwtstrategy depends on the situation. So, If the refresh token and the access...
Read more >
How to get an access token with JWT Grant
This topic demonstrates how to generate an access token manually using JSON Web Token (JWT) Grant authentication. Note: Instead of generating the access...
Read more >
Payload (java-jwt 3.4.1 API) - javadoc.io
The Payload class represents the 2nd part of the JWT, where the Payload value is hold. ... Get the value of the "aud"...
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