'Getting google UID with google AuthToken?

I am trying to implement Google OAUTh2 in a chrome extension where you cant just use the firebase/auth library and signInWithPopup but I got it working ... except one big problem

I configured the manifest

 "oauth2": {
    "client_id": ...
    "scopes": ["email"]
  },

got the auth token

if (request.message === "get_auth_token") {
    chrome.identity.getAuthToken({ interactive: false }, function (token) {
      fetch(
        `https://www.googleapis.com/oauth2/v3/userinfo?access_token=${token}`
      )
        .then((response) => response.json())
        .then((data) => console.log("data", data));
    });

and received my user data with the name and email etc... but not the uid.

But that is the key i am using in my database for the users data. Any chance to get the uid from within a browser extention?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source