7

I'm trying to make a chrome extension, which will have a free trial. Following the documentation here, the first thing to do is enabling Chrome Identity API. As far as i can tell, there's no such thing...

Anyway... I've done every other steps, and ends up with a 500 error.

Here is part of what i've done. Of course i changed values of all ids, keys, token, etc..

manifest.json

    {
      "name": "The name of my app",
      "version": "1.0.9",
      "key": "my_very_long_key",
      "description": "A description",
      "manifest_version": 2,
      "permissions": [ "activeTab", "storage", "declarativeContent", "identity", "https://www.googleapis.com/" ],
      "oauth2": {
        "client_id": "the_client_id_i_setup_in_Credentials_oauth2_section.apps.googleusercontent.com",
        "scopes": [
          "https://www.googleapis.com/auth/chromewebstore.readonly"
        ]
      },
    // other stuff...

code

chrome.identity.getAuthToken({
  'interactive': true
}, (token) => {
  console.log("Token: %o", token);
  console.log("chrome.runtime.id: %o", chrome.runtime.id);

  var CWS_LICENSE_API_URL = 'https://www.googleapis.com/chromewebstore/v1.1/userlicenses/';
  var req = new XMLHttpRequest();
  req.open('GET', CWS_LICENSE_API_URL + chrome.runtime.id);
  req.setRequestHeader('Authorization', 'Bearer ' + token);
  req.setRequestHeader('Content-Type', 'application/json');

  req.onreadystatechange = () => {
    if (req.readyState == 4) {
      var license = JSON.parse(req.responseText);
      console.log(license);
    }
  }
  req.send();
});

And here is an example of output.

Token: "ya29.GlzqBp1FaFegsgm.oihohjbrbznghdfgmgighnzxfvxz3ve5G8GQ4VxZ653FqBa8aqq-JXil-VS5IGeknneZ6KnKbyknw-gXw"
chrome.runtime.id: "asdflhlkrfhuilerdfb"

Object
    error:
        code: 500
        errors: Array(1)
            0:
                domain: "global"
                message: "Backend Error"
                reason: "backendError"
                __proto__: Object
            length: 1
            __proto__: Array(0)
        message: "Backend Error"
        __proto__: Object
    __proto__: Object

So i'm able to obtain the access token, but then calling the API with it doesn't seem to lead to anything.

5
  • Why did you add a key parameter to the URL???
    – wOxxOm
    Apr 13, 2019 at 4:16
  • 'Cause it wasn't working, it's a try. This isn't described in the documentation link i provided, but i read it somewhere else, that to use Chrome Web Store APIs, you must provide the api key. I'll remove it anyway, since i also don't think that's required.
    – JSlain
    Apr 13, 2019 at 12:14
  • Have the same problem. I followed all the instructions and also the example they give, still getting backend error. I guess it's a fault on their side
    – E Ciotti
    Apr 23, 2019 at 10:56
  • @JSlain got the solution? I'm getting the same error. please help. Aug 18, 2019 at 4:06
  • 1
    @muazz nope... and i still can't believe this api is broken and nobody even care. It's the api that makes people pay! Thats crazy...
    – JSlain
    Aug 19, 2019 at 11:13

1 Answer 1

1

Reopened bug: https://issuetracker.google.com/issues/140188619

Please, star it on issuetracker.google.com, if you have the same issue to speed up Google)

UPDATE:

Issue was fixed by Google! https://bugs.chromium.org/p/chromium/issues/detail?id=940478#c18

1
  • They finally fixed it.
    – JSlain
    Aug 31, 2019 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.