Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No pem found for envelope: {"alg":"RS256","kid":"5a66482db3800c83c63","typ":"JWT"}

I'm trying to verify and decode id token sent by front-end. I get this error when i run the verifyfunction. Sometimes it might work.

No pem found for envelope: {"alg":"RS256","kid":"53c666482db3800c83c63","typ":"JWT"}

This is my code

        const ticket = await client.verifyIdToken({
        idToken: token,
        audience: '804312674051-5o4.apps.googleusercontent.com',
    });
    const payload = ticket.getPayload();
like image 570
Kunal Shukla Avatar asked Apr 14 '20 08:04

Kunal Shukla


1 Answers

I finally found the answer today. The Firebase tool will connect the native Google to the third-party login token, and then encapsulate another layer. The token obtained at this time is no longer the original token given to us by Google.

  • A1:
    • Original Token: GoogleDesignInAccount Account = Task.getResult(ApiException.class);
    • Account.getidToken () // This is the original token
  • B1:
    • Firebase token: FireBaseUser currentUser = Mauth.getCurrentUser ();
    • String token = currentUser.getIdToken(false).getResult().getToken();
  • A2:
    • Google officially provides a method to verify the token
  • B2:
    • Firebase officially provides the authentication token method

We use code names for the four data points above. If you need to verify the validity of tokens in the background, they must correspond to each other, A1 to A2 and B1 to B2. If you use A2 to validate the B1, it will fail

like image 184
xuesong zhu Avatar answered Nov 03 '22 02:11

xuesong zhu