simonrob/email-oauth2-proxy

RefreshError('invalid_client: The OAuth client was not found.', {'error': 'invalid_client', 'error_description': 'The OAuth client was not found.'})

Closed this issue · 2 comments

Hello, please do you have idea how to overcome folowing exception 'The OAuth client was not found'

Log:

emailproxy  | 2025-06-05 19:12:47,456: New incoming connection to IMAP server at 0.0.0.0:2993 (unsecured) proxying imap.googlemail.com:993 (SSL/TLS)
emailproxy  | 2025-06-05 19:12:47,456: Accepting new connection from <IP address>:58338 to IMAP server at 0.0.0.0:2993 (unsecured) proxying imap.googlemail.com:993 (SSL/TLS)
emailproxy  | 2025-06-05 19:12:47,460: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) --> [ Client connected ]
emailproxy  | 2025-06-05 19:12:47,460: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-> [ Starting TLS handshake ]
emailproxy  | 2025-06-05 19:12:47,477: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-> [ TLSv1.3 handshake complete ]
emailproxy  | 2025-06-05 19:12:47,484: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993)     <-- b'* OK Gimap ready for requests from client_IP m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,484: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-- b'* OK Gimap ready for requests from client_IP m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,510: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) --> b'0 LOGIN [[ Credentials removed from proxy log ]]\r\n'
emailproxy  | 2025-06-05 19:12:47,800: Caught exception while requesting OAuth 2.0 credentials for account xxx@domain.cz: RefreshError('invalid_client: The OAuth client was not found.', {'error': 'invalid_client', 'error_description': 'The OAuth client was not found.'})
emailproxy  | 2025-06-05 19:12:47,801: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-- b'0 NO LOGIN Email OAuth 2.0 Proxy: Login failed for account otrssa@extendit.cz - please check your internet connection and retry\r\n'
emailproxy  | 2025-06-05 19:12:47,827: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) --> b'1 EXPUNGE\r\n'
emailproxy  | 2025-06-05 19:12:47,827: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993)     --> b'1 EXPUNGE\r\n'
emailproxy  | 2025-06-05 19:12:47,830: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993)     <-- b'1 BAD Unknown command m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,830: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-- b'1 BAD Unknown command m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,852: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) --> b'2 LOGOUT\r\n'
emailproxy  | 2025-06-05 19:12:47,852: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993)     --> b'2 LOGOUT\r\n'
emailproxy  | 2025-06-05 19:12:47,855: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993)     <-- b'* BYE Logout Requested m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,855: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-- b'* BYE Logout Requested m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,856: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993)     <-- b'2 OK Quoth the raven, nevermore... m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,856: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-- b'2 OK Quoth the raven, nevermore... m11mb7661708ljh\r\n'
emailproxy  | 2025-06-05 19:12:47,856: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) <-- [ Server disconnected ]
emailproxy  | 2025-06-05 19:12:47,856: IMAP (source_IP:58338-{172.21.0.2:2993}-imap.googlemail.com:993) --> [ Client disconnected ]

Test:

root@a1 /home/docker/email-oauth2-proxy-docker # ./send_email.sh
*   Trying 127.0.0.1:2993...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 127.0.0.1 (127.0.0.1) port 2993 (#0)
< * OK Gimap ready for requests from client_IP 2adb3069b0e04-5532d4f9a54mb10012163e87
  0     0    0     0    0     0      0      0 --:--:--  0:00:14 --:--:--     0^C

Config:

cat config/emailproxy.config

# imap.googlemail.com
[IMAP-2993]
#server_address = imap.gmail.com
server_address = imap.googlemail.com
server_port = 993
local_address = 0.0.0.0
#local_address = 127.0.0.1

[SMTP-2465]
server_address = smtp.googlemail.com
server_port = 465
local_address = 0.0.0.0
#local_address = 127.0.0.1

[otrssa@extendit.cz]
#permission_url = https://accounts.google.com/o/oauth2/auth
oauth2_flow = service_account
token_url = https://oauth2.googleapis.com/token
oauth2_scope = https://mail.google.com/
redirect_uri = http://localhost
client_id = file
client_secret = /config/email-oauth2-pro-1748962892448-01ac38008f8b.json

[emailproxy]
delete_account_token_on_password_error = True
encrypt_client_secret_on_first_use = False
allow_catch_all_accounts = False

email-oauth2-pro-1748962892448-01ac38008f8b.json ... JSON from GMAIL CONSOLE

This is very likely to be an invalid configuration in the Google Workspace admin panel (see the error message: The OAuth client was not found). The proxy uses Google's own library to parse the JSON key data, and that would probably fail if the proxy not loading the file.

If you are certain the client is configured correctly, you could add some logging in this method to show the values the proxy is using, and report back here.

I'm going to assume this has been resolved and close this issue, but feel free to reopen if that is not the case.