Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda