Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda