Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

329
Views
Decrypting Google Api Credentials Response

I'm building a "Login with Google" button in my app using the Google API and the official guide, but i got stuck at decrypting the credentials sent by google as a response when login in with google. I get this error: Uncaught SyntaxError: Cannot use import statement outside a module

This is the form file:

<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
   data-client_id="*********************************************"
   data-callback="handleCredentialResponse"
   data-auto_prompt="false"
   >
</div>
<div class="g_id_signin"
   data-type="standard"
   data-size="large"
   data-width="400"
   data-theme="outline"
   data-text="sign_in_with"
   data-shape="rectangular"
   data-logo_alignment="left">
</div>

And a js file login.js dealing with the response:

import * as jose from '../vendor/jose-main/src/index.ts';

function handleCredentialResponse(response) {
    const { payload, protectedHeader } = await jose.jwtDecrypt(response.credential, secretKey, {
      issuer: 'urn:example:issuer',
      audience: 'urn:example:audience'
    })
    console.log(payload);
    console.log(protectedHeader);
     // decodeJwtResponse() is a custom function defined by you
     // to decode the credential response.
     //const responsePayload = decodeJwtResponse(response.credential);
//
//     console.log("ID: " + responsePayload.sub);
//     console.log('Full Name: ' + responsePayload.name);
//     console.log('Given Name: ' + responsePayload.given_name);
//     console.log('Family Name: ' + responsePayload.family_name);
//     console.log("Image URL: " + responsePayload.picture);
//     console.log("Email: " + responsePayload.email);
  }

Anyone knows how to solve this issue?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!