Nicholas Brandt
Nicholas Brandt

Reputation: 374

chrome.identity.getAuthToken: proper error documentation

ChromeOS Version 63.0.3239.140 (Official Build) (64-bit)

Hi there,

I got several different errors while using https://developer.chrome.com/apps/identity#method-getAuthToken but couldn't find any (doc) information about the actual meaning of those errors or their solutions. I'm building a new chrome extension.

Problem: However, I get a "The user is not signed in."-error when calling chrome.identity.getAuthToken({interactive: true}) from a browser-action popup context.

Expected behavior: My code is derivated from https://github.com/firebase/quickstart-js/blob/master/auth/chromextension/credentials.js which works nicely by showing a Google sign-in page.

Hint: I didn't upload/publish my extension to the Chrome web store as Google requires a registration fee and I don't own a credit card. This is the only distinction I'm able to discover.

Manifest:

{
  "manifest_version": 2,

  "name": "Hull",
  "description": "Archives all web requests.",
  "version": "1.0",
  "content_security_policy": "script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'",
  "oauth2": {
    "client_id": "354393906319-rn6mosmrpisn6n8ru5n930a8hspqthjn.apps.googleusercontent.com",
    "scopes": [
      "https://www.googleapis.com/auth/userinfo.email"
      ]
  },
  "browser_action": {
    "default_popup": "popup.html"
  },
  "permissions": [
    "identity",
    "<all_urls>"
  ],
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo5fm22ivystD4/Me0vIM/T+9I3CvBY8nb8GacdMADE7Xn6VauUqNUzpeZWZGh4gjj9SpryVGeMWiCBaLvbveqbcTIvx0WF6ltFqJBOcqEaZs9LwYsGf+38PUWuQ6bY9G67AjWuw3A0PB9+ilPC/VYH8gHIoBesu6yE2yOdJ2eUhXzT3+eAnPNhUvpMK+ZFuxCurqpvRXIGVU+xYonWQ6c/cK/oLjHQPBiEjnyg/bsqcg/4rZZA9Ux7GbbfFgWHdRRACR+mWSviEkzI7DDHTcHg6pchLzUhAzoy3LbZGTxrpHp7fcN5PLcVPNrhtS3v6OgALnOBVAVuKXS/vtK8rqvQIDAQAB"
}

Popup.js:

document.querySelector("input").addEventListener("click", () => {
  const result = chrome.identity.getAuthToken({interactive: true}, token => {
        console.log("token", token);
    });
});

So, where can I find information about any chrome.identity related errors and is uploading/publication necessary to get the identity methods working.

Thanks in advance.

BTW: I read https://developer.chrome.com/apps/app_identity but that site only state that methods throw errors in general and doesn't list nor explain them in detail.

Upvotes: 0

Views: 878

Answers (1)

Nicholas Brandt
Nicholas Brandt

Reputation: 374

So, I figured out that my extension's manifest.json was misconfigured.

The Chrome extension does not need to be published but the Client-ID in the Google Console must be created via "Chrome App" (see chrome.identity User Authentication in a Chrome Extension for details).

Hope this helps somebody.

Still error documentation is basically non-existent which I'm not used to from Google software.

Upvotes: 2

Related Questions