core icon indicating copy to clipboard operation
core copied to clipboard

Cannot connect to G Suite account

Open rrthomas opened this issue 6 years ago • 17 comments

(Before I start, I'd like to say THANKS VERY MUCH for all the hard work the devs have done on this issue. It's much appreciated!)

  • Operating System (Linux/Mac/Windows/iOS/Android): Android
  • Delta Chat Version: 1.10.4
  • Expected behavior: Should now be able to connect to a G Suite account
  • Actual behavior: Fails with an error (see below)
  • Steps to reproduce the problem:
    1. Start DeltaChat
    2. Enter my email address.
    3. I am offered "Continue with simplified setup?"
    4. I touch "CONTINUE".
    5. I am taken to a web browser flow to authorize Delta Chat, which I do.
    6. It takes me back to DeltaChat, where a progress meter goes up to 66% before giving the following error:

image

  1. I get a Google alert saying that DeltaChat now has access to my account, so it seems the authorization flow worked.

I note that the host mentioned in the error, imap.sc3d.org, does not exist. When I check the instructions in GMail for accessing my account via IMAP, it says I should use imap.gmail.com.

rrthomas avatar Jul 26 '20 19:07 rrthomas

Did it work on any previous version?

link2xt avatar Jul 26 '20 20:07 link2xt

This is the first version I've tried with OAuth2 flow support for G Suite domains, which has only recently been introduced. In the past I've had it working with plain IMAP support.

rrthomas avatar Jul 26 '20 20:07 rrthomas

This imap.sc3d.org address comes from the configure procedure, appending imap to the domain in attempt to guess the correct domain: https://github.com/deltachat/deltachat-core-rust/blob/f7d6230a978df889a5fbae8332ad510a88d45ba2/src/configure/mod.rs#L196 Apparently OAuth2 detection was added in #1626 recently, but actual configuration was not tested.

cc @mmoya

link2xt avatar Jul 27 '20 12:07 link2xt

If you can't configure these settings manually, it is a bug in Android app, probably?

As for core, these settings should probably be hardcoded into the app for better autoconfiguration. Thunderbird source can be used for that (https://searchfox.org/comm-central/source/mailnews/base/util/OAuth2Providers.jsm), it is MPL licensed, just like the core.

link2xt avatar Jul 27 '20 17:07 link2xt

I believe it is not possible to use manual settings with OAuth, so I don't know about that.

rrthomas avatar Jul 27 '20 18:07 rrthomas

Getting back to this old issue...

it actually is strange that this stopped working when you started using OAuth. Can you please test if this works again if you hit "Cancel" when it asks you about OAuth and just type in your password as before?

Also, to get your account working (80% sure this works)

  • start Delta Chat
  • Tap "Log in to your server"
  • tap "Advanced"
  • in "IMAP server" fill imap.gmail.com
  • in "SMTP server" fill your smtp server, probably smtp.gmail.com
  • Go to the top, enter your email address and continue with OAUTH setup.

Hocuri avatar Sep 25 '20 17:09 Hocuri

Getting back to this old issue...

it actually is strange that this stopped working when you started using OAuth. Can you please test if this works again if you hit "Cancel" when it asks you about OAuth and just type in your password as before?

This now works: Google's servers seem to have relented. A few months ago, I had trouble using anything with old-style passwords; as I said, DeltaChat had worked in the past, and started working again later.

However, it is still flaky: it often fails to connect or takes a long time, and only works on wifi; on mobile data I get 100% authentication failure messages.

I set up my own mail server with regular IMAP, and it works flawlessly.

Also, to get your account working (80% sure this works)

* start Delta Chat

* Tap "Log in to your server"

* tap "Advanced"

* in "IMAP server" fill `imap.gmail.com`

* in "SMTP server" fill your smtp server, probably `smtp.gmail.com`

* Go to the top, enter your email address and continue with OAUTH setup.

Tried this, progress got stuck at "One moment… 60%", and eventually timed out, giving an error that it couldn't reach the server whose name it deduced from my email address (ignoring the server name I had filled in).

rrthomas avatar Sep 25 '20 17:09 rrthomas

In the next version the configuration will be improved and there will be better error messages. Maybe makes sense to wait until then.

Hocuri avatar Sep 26 '20 07:09 Hocuri

@rrthomas yet another idea: how much work would it be to get me an email address on your g suite account? You could send me the credentials to hocuri1 at testrun.org. Is it possible to do this with G Suite?

Hocuri avatar Oct 05 '20 16:10 Hocuri

That's very kind; unfortunately I'm not the sysadmin and it wouldn't be possible to get a test account.

rrthomas avatar Oct 05 '20 16:10 rrthomas

Ok next idea: You can download the beta from https://testrun.org/deltachat-gplay-release-1.13.4.apk. With lots of luck everything will work just fine (don't fill advanced settings, just follow the normal Oauth flow).

But we will at least get a better error message to finally fix this.

Hocuri avatar Oct 06 '20 09:10 Hocuri

I downloaded and installed the beta, and then tried to set up my account. I put in my email address, went through the OAuth flow, and progress then went up to 60%, crawled up to 78% (took about 10 minutes), and then finally seemed to time out; I say "seemed" because there was no error, I was just back at the DeltaChat login screen. The password was filled in, and when I tapped the ✓ symbol, I was offered the "Continue with simplified setup?" dialog again. I tried once more, with the same result.

rrthomas avatar Oct 06 '20 11:10 rrthomas

I was able to set up gsuite successfully but i did not have to go through the oAuth period by following these directions on MacOS. Android is stuck at 60%

https://github.com/deltachat/deltachat-core-rust/issues/1759#issuecomment-699057182

teach-ed avatar Dec 12 '20 04:12 teach-ed

I have opened REPL and typed in:

> set addr <my address>
> oauth2

Then opened the link in Chromium, followed oauth2 authentication and got the code (my chromium tries to open delta chat app via xdg-open and fails, but I can get the code).

I put the code into mail_pw and do set server_flags 2. Then I type configure.

First problem is that delta chat tries to guess hosts instead of using imap.gmail.com and smtp.gmail.com. So I set mail_server and send_server and typed configure again. This time SMTP connected successfully, but IMAP tries to connect to imap.gmail.com:143 first, which is firewalled, so I have to wait some huge timeout. However, connection finally succeeds.

We need to make sure mail_server, mail_port, send_server and send_port are set correctly in this case, it seems to be the only problem.

Correct server settings are listed here: https://developers.google.com/gmail/imap/imap-smtp

link2xt avatar Dec 23 '20 21:12 link2xt

Delta Chat currently uses MX record to find OAuth2 URLs and other configuration. But during provider database lookup we only look at common autoconfig URLs and user domain. Thunderbird falls back to MX record even for IMAP and SMTP host/port configuration: https://hg.mozilla.org/comm-central/file/333e0623a505d8a0133bd79df39d78bf9fd4dbaf/mail/components/accountcreation/content/fetchConfig.js#l180

Our OAuth2 code is ok, all we need to do is lookup MX record during autoconfiguration if we have not found user domain in provider database, before resorting to guessing.

link2xt avatar Dec 24 '20 10:12 link2xt

I have successfully created an account and sent a message using current Android version of Delta Chat. How to:

  1. Fill login. If offered OAuth2 setup, cancel it.
  2. Open advanced settings and type in login and port: imap.gmail.com:993 and smtp.gmail.com:465. Otherwise you will have to wait a long timeout at 66%, because DC will try firewalled IMAP port 143 first.
  3. Click the tick at the top and proceed with OAuth2 setup.

You can also do it by filling in advanced settings before typing in your login and accept OAuth2 the first time it is offered.

link2xt avatar Dec 24 '20 16:12 link2xt

This should work completely automatically now, can be tested with the latest nightly: https://download.delta.chat/android/nightly/2021-01-09/

link2xt avatar Jan 09 '21 22:01 link2xt