mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Remove default client ID for Google
Change the documentation accordingly Fix #407
This commit is contained in:
parent
69b88dd0c0
commit
12c22f19c0
3 changed files with 36 additions and 37 deletions
|
|
@ -133,6 +133,28 @@ To use this storage type, you need to install some additional dependencies::
|
||||||
|
|
||||||
pip install vdirsyncer[google]
|
pip install vdirsyncer[google]
|
||||||
|
|
||||||
|
Furthermore you need to register vdirsyncer as an application yourself to
|
||||||
|
obtain ``client_id`` and ``client_secret``, as it is against Google's Terms of
|
||||||
|
Service to hardcode those into opensource software:
|
||||||
|
|
||||||
|
1. Go to the `Google API Manager <https://console.developers.google.com>`_ and
|
||||||
|
create a new project under any name.
|
||||||
|
|
||||||
|
2. Within that project, enable the "CalDAV" and "CardDAV" APIs. There should be
|
||||||
|
a searchbox where you can just enter those terms.
|
||||||
|
|
||||||
|
3. In the sidebar, select "Credentials" and create a new "OAuth Client ID". The
|
||||||
|
application type is "Other".
|
||||||
|
|
||||||
|
You'll be prompted to create a OAuth consent screen first. Fill out that
|
||||||
|
form however you like.
|
||||||
|
|
||||||
|
4. Finally you should have a Client ID and a Client secret. Provide these in
|
||||||
|
your storage config.
|
||||||
|
|
||||||
|
You can select which calendars to sync on `CalDav settings page
|
||||||
|
<https://calendar.google.com/calendar/syncselect>`_.
|
||||||
|
|
||||||
.. autostorage:: vdirsyncer.storage.google.GoogleCalendarStorage
|
.. autostorage:: vdirsyncer.storage.google.GoogleCalendarStorage
|
||||||
|
|
||||||
.. autostorage:: vdirsyncer.storage.google.GoogleContactsStorage
|
.. autostorage:: vdirsyncer.storage.google.GoogleContactsStorage
|
||||||
|
|
|
||||||
|
|
@ -207,25 +207,8 @@ Vdirsyncer is continuously tested against the latest version of Baikal_.
|
||||||
Google
|
Google
|
||||||
------
|
------
|
||||||
|
|
||||||
Using vdirsyncer with Google Calendar is possible, but it is not tested
|
Using vdirsyncer with Google Calendar is possible as of 0.10, but it is not
|
||||||
frequently.
|
tested frequently. You can use :storage:`google_contacts` and
|
||||||
|
:storage:`google_calendar`.
|
||||||
::
|
|
||||||
|
|
||||||
[storage cal]
|
|
||||||
type = google_calendar
|
|
||||||
token_file = ~/.google-token
|
|
||||||
|
|
||||||
[storage card]
|
|
||||||
type = google_contacts
|
|
||||||
token_file = ~/.google-token
|
|
||||||
|
|
||||||
At first run you will be asked to authorize application for google account
|
|
||||||
access. Simply follow the instructions.
|
|
||||||
|
|
||||||
- Google's CardDav implementation is very limited, may lead to data loss, use
|
|
||||||
with care.
|
|
||||||
- You can select which calendars to sync on `CalDav settings page
|
|
||||||
<https://calendar.google.com/calendar/syncselect>`_
|
|
||||||
|
|
||||||
For more information see :gh:`202` and :gh:`8`.
|
For more information see :gh:`202` and :gh:`8`.
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,6 @@ logger = logging.getLogger(__name__)
|
||||||
TOKEN_URL = 'https://accounts.google.com/o/oauth2/v2/auth'
|
TOKEN_URL = 'https://accounts.google.com/o/oauth2/v2/auth'
|
||||||
REFRESH_URL = 'https://www.googleapis.com/oauth2/v4/token'
|
REFRESH_URL = 'https://www.googleapis.com/oauth2/v4/token'
|
||||||
|
|
||||||
CLIENT_ID = ('155040592229-mth5eiq7qt9dtk46j0vcnoometuab9mb'
|
|
||||||
'.apps.googleusercontent.com')
|
|
||||||
CLIENT_SECRET = 'flVXF7jB2A2-YC4rg2sUCCX1'
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from requests_oauthlib import OAuth2Session
|
from requests_oauthlib import OAuth2Session
|
||||||
have_oauth2 = True
|
have_oauth2 = True
|
||||||
|
|
@ -26,13 +22,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
class GoogleSession(dav.DavSession):
|
class GoogleSession(dav.DavSession):
|
||||||
def __init__(self, token_file, url=None, client_id=None,
|
def __init__(self, token_file, client_id, client_secret, url=None):
|
||||||
client_secret=None):
|
|
||||||
# Not a default in function signature, otherwise these show up in user
|
|
||||||
# documentation
|
|
||||||
client_id = client_id or CLIENT_ID
|
|
||||||
client_secret = client_secret or CLIENT_SECRET
|
|
||||||
|
|
||||||
# Required for discovering collections
|
# Required for discovering collections
|
||||||
if url is not None:
|
if url is not None:
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
@ -96,8 +86,8 @@ class GoogleSession(dav.DavSession):
|
||||||
|
|
||||||
GOOGLE_PARAMS_DOCS = '''
|
GOOGLE_PARAMS_DOCS = '''
|
||||||
:param token_file: A filepath where access tokens are stored.
|
:param token_file: A filepath where access tokens are stored.
|
||||||
:param client_id/client_secret: OAuth credentials. Hardcoded ones are
|
:param client_id/client_secret: OAuth credentials, obtained from the Google
|
||||||
provided, you shouldn't need this unless you hit API rate limits.
|
API Manager.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -124,8 +114,8 @@ class GoogleCalendarStorage(dav.CaldavStorage):
|
||||||
|
|
||||||
storage_name = 'google_calendar'
|
storage_name = 'google_calendar'
|
||||||
|
|
||||||
def __init__(self, token_file, client_id=None, client_secret=None,
|
def __init__(self, token_file, client_id, client_secret, start_date=None,
|
||||||
start_date=None, end_date=None, item_types=(), **kwargs):
|
end_date=None, item_types=(), **kwargs):
|
||||||
super(GoogleCalendarStorage, self).__init__(
|
super(GoogleCalendarStorage, self).__init__(
|
||||||
token_file=token_file, client_id=client_id,
|
token_file=token_file, client_id=client_id,
|
||||||
client_secret=client_secret, start_date=start_date,
|
client_secret=client_secret, start_date=start_date,
|
||||||
|
|
@ -141,6 +131,11 @@ class GoogleCalendarStorage(dav.CaldavStorage):
|
||||||
|
|
||||||
class GoogleContactsStorage(dav.CarddavStorage):
|
class GoogleContactsStorage(dav.CarddavStorage):
|
||||||
__doc__ = '''Google contacts.
|
__doc__ = '''Google contacts.
|
||||||
|
|
||||||
|
.. note: Google's CardDAV implementation is allegedly a disaster in terms
|
||||||
|
of data safety. See `this blog post
|
||||||
|
<https://evertpot.com/google-carddav-issues/>`_ for the details.
|
||||||
|
Always back up your data.
|
||||||
''' + GOOGLE_PARAMS_DOCS
|
''' + GOOGLE_PARAMS_DOCS
|
||||||
|
|
||||||
class session_class(GoogleSession):
|
class session_class(GoogleSession):
|
||||||
|
|
@ -151,8 +146,7 @@ class GoogleContactsStorage(dav.CarddavStorage):
|
||||||
|
|
||||||
storage_name = 'google_contacts'
|
storage_name = 'google_contacts'
|
||||||
|
|
||||||
def __init__(self, token_file, client_id=None, client_secret=None,
|
def __init__(self, token_file, client_id, client_secret, **kwargs):
|
||||||
**kwargs):
|
|
||||||
super(GoogleContactsStorage, self).__init__(
|
super(GoogleContactsStorage, self).__init__(
|
||||||
token_file=token_file, client_id=client_id,
|
token_file=token_file, client_id=client_id,
|
||||||
client_secret=client_secret,
|
client_secret=client_secret,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue