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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With