1. Create a free Gmail account, in our case, it will be
scastatagent@gmail.com then go to the
Google Console dashboard. Replace scastatagent@gmail.com with your <gmail_account_name@gmail.com>.
2. Create a new
Project name. In our case, it will be
scagmail.
3. Go to
APIs & Services.4. Click on
ENABLE APIS AND SERVICES.5. Search for
Gmail API and
enable it.
6. Now go to
Create Credentials. 7. Now select your chosen application type. We will use the
WEB application type. You can see the Client ID and Secret ID that can be saved. Download it and save the .json file.
8. Now
add a redirect URI. After the user is authenticated with Google, this will be redirected to the Client that asked for the authentication. In our case, we will use
https://localuri.com.
The path will be appended with the authorization code for access and must have a protocol.
It can’t contain URL fragments, relative paths, or wildcards, and can’t be a public IP address.
For STAT core functionalities to work, we would need to add the following more redirect URIs:
http://localhost:8888/Callback
http://localhost:8889/Callback
http://localhost:8890/Callback
http://localhost:8892/Callback
http://localhost:8891/Callback9. After saving the previous section, go to the
OAuth consent Screen and click on the
Edit App button.
At this point, we have to complete the four steps to define the Consent, the Scope, and the user for our registered app (This should grant us access to the test application project).
This is done by going to the bottom and clicking on the button Save and Continue.
For the Scope, Google will show more than 100 GMail APIs and it is very important to select the proper needed for Stat.
We selected all the APIs related to the /auth/ for example all those that log in to the Gmail inbox, read, modify, delete, and Send.
10. Then fill in the User for testing. It should be the same account for which you enabled Google IMAP or SMPT in the Gmail Settings | Forwarding and POP/IMAP section.
11. In the Stat Windows Application, go to Maintenance | Stat Central Agent | Email Settings | Configuration
In our case, we will be configuring IMAP. Make sure to select the authentication type as OAuth 2.0, check the security settings is set as TLS and the port is set at 993 then click on the OAuth details drop-down.
a. Mark Prompt as consent. Make sure to fill it lower case as this is case sensitive.
b. For Client Id and Client Secret, fill in the related info you saved previously in Notepad or in JSON format.
c. The Authorization endpoint URL should be https://accounts.google.com/o/oauth2/auth
d. The Token endpoint URL should be https://accounts.google.com/o/oauth2/token
e. For Redirect URI refer to step 8 of the GCP section above: https://localuri.com
f. The scope should be https://mail.google.com
Apply and do the Test Connection.
NOTE: For the SMPT, the values will be the same of the IMAP. You only must change the Email server and the port to TLS. The OAuth 2.0 login screens are the same for both SMTP and IMAP, and you only need to click Continue.
For MFA enabled:The user is unable to connect via SMTP. If MFA / 2FA is enabled for the Gmail account, then actual passwords won’t work while connecting.
The user needs to use
app passwords, instead of their actual passwords.
1. Go to your
Google Account.
2. Select Security.
3. Under "Signing into Google," select App Passwords. You may need to sign in. If you don’t have this option, it might be because:
- 2-Step Verification is not set up for your account.
- 2-Step Verification is only set up for security keys.
- Your account is through work, school, or other organizations.
- You turned on Advanced Protection.
4. You need to select an app
5. Select
other in app
6. Give any name that you want. In this case, it will be
STATAppPwd.7. Gmail will now generate an app password and it would be shown in a form of a prompt.
8. Use this password with your email ID in STAT while connecting through SMTP.