eclipse-ee4j / eclipse-ee4j/angus-mail
SMTP XOAUTH2 authentication fails with large access tokens
- Dominant language
- Java
- Stars
- 87
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
While configuring OAuth authentication through the Jenkins email-ext plugin, we came across a potential limitation when handling large OAuth access tokens.
The email-ext plugin uses Angus Mail as its underlying mail API. When attempting SMTP authentication against Google Workspace using OAuth 2.0 and a token sized at ~1024 characters, authentication fails with the following server response:
```
555-5.5.2 Syntax error, command line too long
```
The same configuration works as expected when shorter access tokens are used. I believe this error may be related to RFC 4954 section 4 actually specifies that if the initial response would cause the AUTH command to exceed the line length limit, the client must not send it inline and should instead send AUTH XOAUTH2, no token, wait for the server's 334 challenge, and then send the token on its own line (which has no length restriction). This is the two-step exchange.
**To Reproduce**
1. Set up Jenkins with the email-ext plugin.
2. Configure SMTP authentication using Google Workspace and Domain Wide Delegation.
3. Obtain an OAuth access token with a length of ~1024 characters.
4. Configure the plugin to authenticate using the generated token.
5. Attempt to send a test email
**Expected behavior**
Authentication should succeed regardless of token length, provided the token is valid and accepted by the mail provider.
**Actual behavior**
SMTP server responds with:
```
555-5.5.2 Syntax error, command line too long
```
**Screenshots**
Not available.
**Desktop (please complete the following information):**
* OS: Windows 11 with WSL Ubuntu
* Browser: N/A
* Version: N/A
**Smartphone (please complete the following information):**
* Device: N/A
* OS: N/A
* Browser: N/A
* Version: N/A
**Mail server:**
* Protocol being used: SMTP
* Vendor/product: Google Workspace
* Mail service URL: smtp.gmail.com
**Additional context**
* This behavior appears similar to issues reported in other projects, for example: https://github.com/pear/Net_SMTP/pull/70
Contributor guide
Research direction
Start by locating the SMTP XOAUTH2 authentication entry point in Angus Mail and compare its AUTH command handling with RFC 4954 section 4. Reproduce the issue against smtp.gmail.com using a roughly 1024-character token; done means the client uses the two-step exchange and authentication succeeds without the 555 line-length error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100