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

310
Vistas
Javascript: Why is Gapi not working with Chrome Extension?

Why isn't the gapi library working with my chrome extension?

In background.js I loaded the script. When using oauth2, the promise from the init function does not return and nothing is logged. However, when I remove oauth2 (clientId and scope) then the promise returns and 'GAPI INITED' is logged.

Any idea why gapi works without oauth2 but then doesn't work with oauth2? Any workarounds?

Gapi Loaded:

var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "https://apis.google.com/js/client.js";
head.appendChild(script);
window.onload = function () {
  setTimeout(function () {
    gapi.load('client:auth2', initClient);
  }, 500);
};

function initClient() {
  console.log('GAPI PRE INIT');

  gapi.client.init({
      apiKey: API_KEY,
      discoveryDocs: DISCOVERY_DOCS,
      clientId: CLIENT_ID, //Only access 'GAPI INITED' when this line is commented out
      scope: SCOPE //Only access 'GAPI INITED' when this line is commented out
  }).then(function () {
    // Listen for sign-in state changes.
    console.log('GAPI INITED');
    gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);

    
  });
}

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