问题
I would like to use the new Google App password for Google Calendar feature in a Ruby script but can't find a gem or example. In the past you could logon with your google email and password but that stopped working a long time ago, tighter security..
I have an older example which uses oAuth and tokens etc but would like to try this much simpler approach.
I do have a working script for Gmail like below but would like to use the same way for Calendar, I allready have an app password for Agenda/Windows app. Each service and client needs another password you have to ask in your Google account security settings.
An example of reading the events for the next week would be great.
Here the working example with a Gmail app password.
require 'net/imap'
PASSWORD = 'xxxx xxxx xxxx xxxx' # all lower case letters
imap = Net::IMAP.new("imap.googlemail.com", 993, true, nil, false)
imap.login('xxxxxxxx@gmail.com', PASSWORD)
imap.select('INBOX')
imap.search(['UNSEEN']).each do |message_id|
envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
puts "#{envelope.from[0].name}: #{envelope.subject.clean}"
end
imap.logout()
imap.disconnect()
来源:https://stackoverflow.com/questions/55981592/using-the-google-calendar-app-password-in-ruby