I’m working on a Chrome Extension with the Drive API v3. My OAuth, API key and client_id are working fine. I’m having trouble fetching any data.
I used this as a starting point and it works fine for the People API. I modified the oauth.js code to this:
window.onload = function() {
document.querySelector('button').addEventListener('click', function() {
chrome.identity.getAuthToken({interactive: true}, function(token) {
let init = {
method: 'GET',
async: true,
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json'
},
'contentType': 'json'
};
fetch(
//'https://www.googleapis.com/drive/v3/files?mimeType!='application/vnd.google-apps.folder'',
//'https://www.googleapis.com/drive/v3/files?q=name%20contains%20'Yamaha'',
//'https://www.googleapis.com/drive/v3/files?name='Spices'',
'https://www.googleapis.com/drive/v3/files?q='0Bxl5Z50oMH4MX2E0UXdhQUdUbGs'',
init)
.then((response) => response.json())
.then(response => {
console.log(JSON.stringify(response))
console.log("Done stringify");
console.log(response);
console.log("Done response");
})
});
});
};
The commented lines are attempts at different fetch syntaxes.
For each of these attempts, I do not get any console errors but instead I get the following:
What is the missing piece? Ideally, I’d like to get all the files/folders, their ids and names!