microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
8.29k stars 1.7k forks source link

Implement Google Contact Sync #222

Open isthisme opened 7 years ago

isthisme commented 7 years ago

This would be a nice feature to have since the contact sync .apk from Google is proprietary.

mar-v-in commented 7 years ago

You should be able to sync contacts using the open-source CardDAV client DAVdroid (available on F-Droid). Use the following details to setup the account:

I am not sure if all features are implemented correctly in Google's CardDAV interface. It's the same API used for Apple clients, so it shouldn't be too bad ;)

JonnyTech commented 7 years ago

This only seems to work with Google contacts - is there a way to sync Google calendar too?

mar-v-in commented 7 years ago

It should be possible to install and use the Google Calendar app

JonnyTech commented 7 years ago

I am using CM13 and it has a calendar app - looking at app details it is com.android.calendar version 6.0.1 - but DAVdroid has the issue connecting to the sync service, is there anything that I can check?

mar-v-in commented 7 years ago

There is a dedicated "Google Calendar" app in the Play Store, that's not the same app as the AOSP calendar (or derivates thereof)

ale5000-git commented 7 years ago

There is also a Calendar Sync apk that possibly work together the AOSP calendar but I'm not sure.

JonnyTech commented 7 years ago

Thanks, I found a solution, use the following server url with DAVdroid:

https://www.google.com/calendar/dav/my.email.address@google.com/events

Replace my.email.address@google.com with your full GMail address.

It syncs both my contacts and calendar from that location.

Only my primary calendar is visible but that is all that I need.

Reference: AndroidCaldavSyncAdapater Server Compatibility List

julianwi commented 7 years ago

If somebody needs to sync a non primary calendar, look in the google calendar web interface for the Calendar ID. Press the gear top right, select settings, select calendars, then select the calendar you want to sync. The Calendar ID should be something like d4jg8dj5ng8ek5jdhrn4udje8@group.calendar.google.com Then use https://www.google.com/calendar/dav/my.calendar.id@google.com/events as base URL in DAVdroid. Replace my.calendar.id@google.com with your calendar id.

Lanchon commented 7 years ago

can google contact and/or calendar sync client be used without granting it system permissions?

Lanchon commented 7 years ago

gmail sync is working. i installed GoogleContactsSyncAdapter.apk as a regular app (obtained from opengapps) and i haven't been able to make it work.

UPDATE: yes it works! i had enabled the contacts permission in the GoogleContactsSyncAdapter app, but nothing happened. after a while, CM's privacy guard popped up asking about contact access. i granted that and sync started.

i went to the account but only gmail sync showed. later contact sync appeared. (i installed google's contact app and fiddle with its settings in between, FYI.) everything seems to be working fine.

Lanchon commented 7 years ago

same dance, i installed GoogleCalendarSyncAdapter.apk, enabled the calendar permission, enabled calendar access on the privacy guard popup, and cal sync is working too!

supports multiple calendars.

coyoteltd commented 7 years ago

I'm trying to get this working, but it keeps throwing "Couldn't find CalDAV or CardDAV service."

After some digging, it seems that Google is swatting me down with an authentication error. But why?

JonnyTech commented 7 years ago

Go here: https://accounts.google.com/b/0/displayunlockcaptcha

coyoteltd commented 7 years ago

Thank you! But did not fix. :(

JonnyTech commented 7 years ago

Have you allowed "less secure" access? https://support.google.com/accounts/answer/6010255?hl=en

coyoteltd commented 7 years ago

Also did not fix. :(

JonnyTech commented 7 years ago

Are you using the URLs from https://github.com/microg/android_packages_apps_GmsCore/issues/222#issuecomment-261253801

Can you view your contacts at http://contacts.google.com/

coyoteltd commented 7 years ago

Yes, I can view my contacts just fine. I've tried with every URL in this thread and one I found by Googling.

I've checked my password 20 times (it's definitely right) and tried with myemail, myemail@gmail.com, myemail@googlemail.com. . .

The logs just say "Invalid Credentials" every time.

JonnyTech commented 7 years ago

Is there a special character in your password? Try setting it to something simple. Ref: https://davdroid.bitfire.at/faq/entry/password-not-accepted/

anunaym14 commented 7 years ago

I refereed to the second post here to setup DAVDroid with microg but the error I get is CalDAV/CardDAV service not found! Please help ASAP!

JonnyTech commented 7 years ago

Keep reading... see my reply above: https://github.com/microg/android_packages_apps_GmsCore/issues/222#issuecomment-261253801

anunaym14 commented 7 years ago

Tried it! Same error! I have to replace it with my email right? I tried by replacing to anunaym14@gmail.com and got the same error!

anunaym14 commented 7 years ago

If u want I can send you logs via telegram. Ping me @anunaym14

JonnyTech commented 7 years ago

In DAVdroid: Add account >> Select "Login with URL and user name"

Base URL = https://www.google.com/calendar/dav/anunaym14@gmail.com@google.com/events User name = anunaym14@gmail.com Password = \<your-password>

I just checked it with my account and it works.

Did you allow "less secure apps" on your google account? https://github.com/microg/android_packages_apps_GmsCore/issues/222#issuecomment-269888617

anunaym14 commented 7 years ago

How to allow "less secure apps" on google account? I tried again, didn't work!

JonnyTech commented 7 years ago

It is best to do it on a computer:

Now you can use non Google products, such as DAVdroid to access your account

Also try this: https://accounts.google.com/b/0/displayunlockcaptcha

JonnyTech commented 7 years ago

I do not understand your question. If it is not related to this issue then please open another.

EDIT: I see that you deleted your last post...

anunaym14 commented 7 years ago

Thank you so much for this blazing fast support!

Edit : Yes, I deleted it because its solved!

matttbe commented 6 years ago

Hello,

Thank you for the tip but note that it seems the previous URL is deprecated. I was able to use something like for my "business" account:

https://calendar.google.com/calendar/dav/<full@email.tld>/events

But we should use one of these two URLs:

https://apidata.googleusercontent.com/caldav/v2/<CAL_ID>/user
https://apidata.googleusercontent.com/caldav/v2/<CAL_ID>/events

More info: https://developers.google.com/google-apps/calendar/caldav/v2/guide

ildar commented 6 years ago

https://github.com/microg/android_packages_apps_GmsCore/issues/222#issuecomment-268444784 is worth adding to FAQ. Properly rephrased, of course.