Пользователь уже авторизовал свою учетную запись gmail с помощью входа в Google из Google Actions. Теперь мне нужно вставить список событий в календарь пользователей Google, но я столкнулся с какой-то проблемой или не знаю, как ее создать. Я новичок в календаре API, поэтому, пожалуйста, сообщите мне, как ее решить.
const {google} = require('googleapis');
var calendar = google.calendar('v3');
const SCOPES = ['https://www.googleapis.com/auth/calendar'];
const client_secret = "xyz";
const client_id = "xyz";
const redirect_uris ="xyz";
const oAuth2Client = new google.auth.OAuth2(
client_id, client_secret, redirect_uris);
oAuth2Client.setCredentials({
access_token: 'ACCESS TOKEN HERE'
});
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
};
calendar.events.insert({
auth: oAuth2Client,
calendarId: 'primary',
resource: event,
}, function(err, event) {
if (err) {
console.log('There was an error contacting the Calendar service: ' + err);
return;
}
});
- Как получить доступ к пользовательскому календарю Google с помощью полученного идентификатора из действий Google?
- Как вставить несколько событий в календарь пользователя?.