We are trying to develop a process to send emails using Gmail's SMPT server. As everyone is aware, access to the server will be restricted from less secure apps in the fall of 2024. We are modifying our application to use OAuth 2.0 authentication to gain access.
First, using a personal Google account, we logged into cloud.google.com and setup a new project for emailing. In it we enabled the Gmail API. We then configured the OAuth consent screen for external and in test with the following scopes:
The credentials for An OAuth 2.0 Client ID was created.
We configured our application to use the client ID and secret to obtain an access token and refresh token. The logic then uses the access token and scope of "https://mail.google.com/" to send the email. Please note our application is using a third party solution (Chilkat) to send the emails. This process is successful!
The problem is when we use a Google Workspace account to log into cloud.google.com to set this all up. Our application gets an access token and refresh token. However, when the access token and scope of "https://mail.google.com/" is used, the service is rejected with the following response:
ChilkatLog:
SmtpAuthenticate:
DllDate: Nov 17 2022
ChilkatVersion: 9.5.0.93
UnlockPrefix: TBRGES.CB1082025
Architecture: Little Endian; 32-bit
Language: ActiveX
VerboseLogging: 0
ensureSmtpAuthenticated:
smtpAuthenticate:
smtp_host: smtp.gmail.com
smtp_port: 587
smtp_user: xxxxxxxxxx
smtpAuthenticate:
login_method: XOAUTH2
auth_xoauth2:
username: xxxxxxxxx
sendCmdToSmtp:
SmtpCmdSent: {PasswordOrCredentials}
--sendCmdToSmtp
readSmtpResponse:
SmtpCmdResp: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
--readSmtpResponse
--auth_xoauth2
Failed to login using XOAUTH2 method
--smtpAuthenticate
ConnectionType: SSL/TLS
--smtpAuthenticate
--ensureSmtpAuthenticated
Failed.
--SmtpAuthenticate
--ChilkatLog
When you decode the error 334, you get:
{"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}
Any assistance would be greatly appreciated!!!
Thanks
We expected the same results regardless if it was a personal or workspace account.
Found the issue... The Gmail services was turned off for all users in the organization within Google Workspace. Once this was turned on, everything worked as expected!