JavaScrip Gmail API code not working on Django template

im testing a simple Gmail API integration to my django app and its not working. Im trying to migrate the javascript example from the Google docs website, and migrate it to my django proyect, yet doesnt work, and when trying to use the EXACT SAME CODE with the server initialization provided in the docs, it works, why is not working the Gmail API on my django project??

What ive tested?

The error happens to be on the callback of the tokenClient object, is never called and reached, perse because of a code problem.

It indeed opens the prompt of the Google Sign-In in both codebases (django and google recomended), but after that is supposed that the callback is going to be called, but is not (on django).

function handleAuthClick() {
        tokenClient.callback = async (resp) => {
          if (resp.error !== undefined) { // code NEVER REACHED on my django template 
            throw (resp);
          }
          document.getElementById('signout_button').style.visibility = 'visible';
          document.getElementById('authorize_button').innerText = 'Refresh';
          await listLabels();
        };

        if (gapi.client.getToken() === null) {
          // Prompt the user to select a Google Account and ask for consent to share their data
          // when establishing a new session.
          tokenClient.requestAccessToken({prompt: 'consent'});
        } else {
          // Skip display of account chooser and consent dialog for an existing session.
          tokenClient.requestAccessToken({prompt: ''});
        }
      }

NOTE NONE error is printed on the console of neither the server nor the web client, therefore more difficult to know whats happening.

Im not using any template tag that is messing up with the code Django version: latest Python version: latest

Someone please help!

Back to Top