ljanyst / carddav-util

A CardDAV import/export utility
58 stars 22 forks source link

Problem with CardDAV server of Google #13

Open Symnok opened 2 years ago

Symnok commented 2 years ago

Google has its own CardDAV server that does not require OAUTH2 authentication.

Login: xxxxxx@gmail.com (your Gmail email address)

Password: Application specific password (not your Google main password) that can be generated from within security settings of Google Account. You need to enable 2FA first to generate this password.

CardDAV URL: https://www.google.com/carddav/v1/principals/xxxxxx@gmail.com/lists/default/
where xxxxxx@gmail.com your Gmail email address

This settings can be used for accessing Google contacts on PC using standard Mail and Calendar program, on Android (using DAVx5 app), on iPhone (using built-in CardDAV client) and even on Windows 10 Mobile devices.

In all cases, no OAUTH2 Authentication required.

Unfortunately, carddav-util does not work with this server:

symnok@myserver:~/carddav-util$ python3 ./carddav-util.py --download --user=xxxxxx@gmail.com --passwd=abcd1234defg5678 --file=test.vcf --url=https://www.google.com/carddav/v1/principals/xxxxxx@gmail.com/lists/default/ Response:

[i] Downloading from https://www.google.com/carddav/v1/principals/xxxxxx@gmail.com/lists/default/ to test.vcf ... [i] Downloading the addressbook... [!] Error code: 400 b'{\n "error": {\n "code": 400,\n "message": "Request contains an invalid argument.",\n "status": "INVALID_ARGUMENT"\n }\n}\n'

Login and password are correct because when I use incorrect password I get

[i] Downloading the addressbook... [!] Error code: 401 b'{\n "error": {\n "code": 401,\n "message": "Invalid Credentials",\n "status": "UNAUTHENTICATED"\n }\n}\n'

ljanyst commented 1 year ago

I can't help you of the top of my head and don't have the time to investigate at the moment. You seem to have enough skill to figure it out yourself. I'd be happy to accept a pull request.