vdirsyncer
vdirsyncer copied to clipboard
Can't connect to google
Hello,
I am using the version 0.16.8 of vdirsyncer that I installed with pipsi on ubuntu 20.04 server. I followed this guide http://vdirsyncer.pimutils.org/en/stable/config.html to connect to google.
First I had a problem with requests-oauthlib missing so I installed it with
/root/.local/venvs/vdirsyncer/bin/python -m pip install requests-oauthlib
But I now receive the following error when I try to discover:
Opening https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=<my_client_id>&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcarddav&state=<some_code>&access_type=offline&approval_prompt=force ...
warning: No graphical browser found. Please open the URL manually.
Follow the instructions on the page.
Paste obtained code:
Unfortunately, I can't get the code to paste because I receive the following error from google if I open the link in my browser:
The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type. You can create a Client ID for native application at https://console.developers.google.com/apis/credentials/oauthclient
I am sure my client_id and client_secret are correct (as shown in https://console.developers.google.com/apis/credentials)
Do you have any idea how I could fix this?
Thanks for any help
I still can't get it to work. Any idea?
I don't know for sure, but I wonder if it has to do with the "Application Type" you selected when creating your Credentials. I selected "Desktop app." I wonder if there is an application type that prohibits web client type. (I also didn't have a graphical browser and when I pasted the code, everything just worked.)
What @xplreitr suggests sounds correct; can you double check the application type?
sorry for reviving this old issue, but i got the exact same issue
i don't have the "other" application type, i just got :
Just go to "Desktop app" as it is... a Desktop app ;)
Here is the way I followed :
Enable oauth2 for gmail
make new project here
https://console.developers.google.com/apis/api/gmail.googleapis.com/overview
create credentials, ID client oAuth2
- configure oAuth validation screen
- only name off app and twice your email
- validate full access
- add yourself to allowed to test group
Back to credential screen
- Choose desktop app
- generate ID and secret
- register to pass account_ID and account_SEC
generate refresh token with oauth.py from https://github.com/sadsfae/misc-dotfiles
python2 oauth2.py --generate_oauth2_token --client_id=YOUR_CLIENT_ID --client_secret=YOUR_CLIENT_SECRET
or
python2 oauth2.py --generate_oauth2_token --client_id=$(pass account_ID) --client_secret=$(pass account_SEC)
use browser to get the key that will validate the query
copy refresh token or/and register to pass account_RTOKEN
configure offlineimap in offlineimaprc
[Repository account_Remote] type = IMAP remotehost = imap.gmail.com ssl = yes starttls = no ssl_version = tls1_2 remoteuser = [email protected] auth_mechanisms = XOAUTH2 oauth2_client_id = oauth2_client_secret = oauth2_request_url = https://accounts.google.com/o/oauth2/token oauth2_refresh_token = realdelete = yes createfolders= False sslcacertfile = /etc/ssl/certs/ca-certificates.crt
source : https://hobo.house/2017/07/17/using-offlineimap-with-the-gmail-imap-api/ Posted on July 17, 2017 by Will Foster
Indeed, the docs (here: https://github.com/pimutils/vdirsyncer/blob/3191886658f7717c00ec013eb778bc1ced5cef0c/docs/config.rst) should be updated to say "desktop app" instead of other.
I believe the rest is up-to-date. PRs for that are welcome.
seems this is (again?) not working, maybe for security reasons?
there we can read:
"January 31, 2023 - all existing clients are blocked (including exempted clients)"
i have a desktop app, i have client id and secret, but i get same error, complaining about "old" oob mechanism used:
any news on this?
@agolks Please complete the setup flow through google's interface and create a new interface following the instructions here:
https://vdirsyncer.pimutils.org/en/stable/config.html
Can you also confirm which version you're using with vdirsyncer --version
?