Open dhermes opened 10 years ago
I was able to successfully add an "alternate" calendar by doing the following:
from google.appengine.api import users
from models import UserCal
from google_api_utils import InitCredentials
from library import UpdateUserSubscriptions
from google.appengine.ext import ndb
fake_user_id = 'EMAIL.com_ABCD12345'
fake_email = fake_user_id + '@group.calendar.google.com'
fake_user = users.User(email=fake_email, _user_id=fake_user_id)
link = ('webcal://www.tripit.com/feed/ical/private/XYZ/tripit.ics')
user_cal = UserCal(key=ndb.Key(UserCal, fake_user_id),
owner=fake_user,
calendars=[link])
user_cal.put()
CREDENTIALS = InitCredentials()
UpdateUserSubscriptions(user_cal, credentials=CREDENTIALS, defer_now=True)
Before allowing users to do this I would need to get an OAuth 2.0 token for the user for the calendar scope and then verify that they had access to the calendar they were requesting.
When specifying a new ICS endpoint, also enable the user to specify a specific calendar for the invite to be created within.
Background: I use a separate calendar for Tripit and color code it so that travel info stands out. Without Having this feature the travel events are created along with everything else in the primary calendar, making it harder to see them.
NOTE: Migrated from Google Code Hosting