我正在使用Google 的服务帐户在 Google 日历中创建一个新活动,并且我也将sendNotifications设置为 true,但是创建活动后,邀请电子邮件没有发送给与会者??
# new event to be created
event = {
'summary'=> summary,
'description'=> description,
'start'=> {'dateTime' => datetime },
'end' => {'dateTime' => datetime },
'sendNotifications' => true,
'sequence' => sequence,
'reminders' => {
'useDefault' => false,
'overrides' => [
{'minutes' => 60, 'method' => 'email'}
]
},
'attendees'=> [
{
'email'=> email
}
]
}
# build client
client = Google::APIClient.new application_name: "Test", application_version: "0.0.1"
key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file, key_secret)
client.authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => 'https://www.googleapis.com/auth/calendar',
:issuer => ENV['SERVICE_ACCOUNT_EMAIL'],
:grant_type => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
:access_type => 'offline',
:signing_key => key
)
# fetch access token
client.authorization.fetch_access_token!
# create new event
service = client.discovered_api('calendar', 'v3')
client.execute(:api_method => service.acl.insert,
:parameters => {'calendarId' => 'primary'},
:body => JSON.dump(event),
:headers => {'Content-Type' => 'application/json'})