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

105
Views
Javascript login by Google returning null to callback function

I have installed Google Login Button in this website that already have Facebook Login. First, the library:

<script src="https://accounts.google.com/gsi/client" async defer></script>

Than the button:

<div id="g_id_onload"
     data-client_id="myid.apps.googleusercontent.com"
     data-context="signin"
     data-ux_mode="popup"
     data-callback="loginGoogle"
     data-auto_prompt="false">
</div>

<div class="g_id_signin"
     data-type="standard"
     data-shape="rectangular"
     data-theme="filled_blue"
     data-text="signin_with"
     data-size="large"
     data-logo_alignment="left">
</div>

Finally the callback function

var loginGoogleRes;
function loginGoogle(response) {
    loginGoogleRes = parseJwt(response.credentials);
    loginLogar("google");
}

But there is still the jwd parser...

function parseJwt(token) {
    var base64Url = token.split('.')[1];
    var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
    var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
        return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
    }).join(''));

    return JSON.parse(jsonPayload);
}

And at this point token is null, therefore loginGoogle is receiving null value. Before this null issue, the button works ok, ask for my permission, etc, but it will stop here. Maybe some async method, I am also struggling with Dreamweaver that won't work with async methods, plus I'm kinda lost in Google's documentation, it is my first time. Can you help me?

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!