The following Apps Script code in a Chrome extension does not error, but return no calendars:
chrome.identity.getAuthToken({interactive: true}, function(token)
{
var init =
{
method: 'GET',
async: true,
headers:
{
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json'
},
'contentType': 'json'
};
fetch('https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer&key=' + apiKey, init)
.then(function(data)
{
log('Object ' + JSON.stringify(data));
});
});
I just get this in the console: Object {}
I saw this post and tried the suggestions, no luck. The apiKey came from the API console, and works in a different call. Thanks for any tips or pointers.
Edit #2: Here is my current manifest.json:
"oauth2": {
"client_id": "123456780416-17ur6mlc88sfot8e4s2pq05ehtkd8klh.apps.googleusercontent.com",
"scopes":[
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/contacts.readonly",
"https://www.googleapis.com/auth/calendar"
]
}