How to configure SMTP to use OAuth 2.0 (Microsoft & Gmail)? - LabCollector

Search Knowledge Base by Keyword

You are here:
← All Topics

SMTP OAuth2 is an essential feature for LabCollector users who want to comply with Microsoft and Gmail’s secure SMTP integration requirements. This feature is now available in the latest version of LabCollector and allows users to connect their Office365 and Gmail accounts in a secure and reliable way.

OAuth2 is an open standard for authorization that enables users to share their private resources, such as email, with a third-party application without sharing their credentials. This is achieved by using an authorization code, which is generated by the user’s email service provider and exchanged for an access token.

Using OAuth2 in LabCollector has several benefits. Firstly, it allows users to read a user’s data from another application, such as Office365or Gmail , without having to share their credentials. This is especially useful for lab managers who need to access important data such as email correspondence for research purposes.

Secondly, OAuth2 supplies the authorization workflow for web, desktop applications, and mobile devices. This means that users can access their email from any device or platform that supports LabCollector, as long as they have an internet connection.

Finally, OAuth2 is a server-side web app that uses an authorization code and does not interact with user credentials. This means that user credentials are never stored in the LabCollector database, ensuring the highest level of security and privacy for users.

For example, a lab manager who wants to use LabCollector to manage their lab’s email correspondence can use SMTP OAuth2 to connect their Office365 or Gmail account. Once the connection is established, the lab manager can access all of their email correspondence from within LabCollector, without having to leave the application or share their credentials.

In the following Knoweldge Base, we will cover all the essential steps that you need to follow in order to set up your Microsoft’s & Gmail’s OAuth2.

1. OAuth 2.0 Microsoft

2. OAuth 2.0 Google

1. OAuth 2.0 Microsoft

  • First of all, you will need to create an account within the application:
    • 1. create an account on https://portal.azure.com/
    • 2. Go to Azure Active Directory located at the main menu (as shown in the screenshot below).

 

      • Or you can access it, by using the search bar (as shown below).

    • 3. Then, go to “App registrations

    • 4. Now, go to New registration, and fill the required information.

    • 5. Click on “Register button”.
    • 6. Then, copy & paste the following info:
      • Application (client) ID to “OAUTH CLIENT ID” field on Labcollector.
      • Directory (tenant) ID to “TenantID” field on Labcollector.

    • 7. Go to “Certificates & secrets”, then click on “New Client secret”.

    • 8. Fill the description and define the Expires field, then click on Add.

    • 9. Copy & Paste: Client Secret value to “OAUTH SECRET KEY” field on Labcollector.

  • LabCollector’s Configuration
    1. OAUTH USER EMAIL field could be the same as your Azure email account.
    2. OAUTH CLIENT ID field : Application (client) ID in your Azure Active Directory.
    3. OAUTH SECRET KEY field : Azure Active Directory > Certificates & secrets > Client secrets > Value.
    4. TenantID field: value of Directory (tenant) ID in your Azure Active Directory.
    5. Provider: Microsoft.
    6. From field: Could be the same as your Azure email account.
    7. Click on “Get token”.
    8. Click on “Next”.
    9. Input your Password and click on Connect.

    • 10. Click on OK and press on “UPDATE”.

    • 11. Now, you can test using the button “Send test email”.

  • Common error messages
    • Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox.

    • To solve the error, all you have to do is follow the below steps:
      • 1. Go to Microsoft 365 admin center.
      • 2. Click on Users > Active users.
      • 3. Click on your current user.

      • 4. Click on “Mail” > “Manage email apps”.

      • 5. Be sure that “Authenticated SMTP” is active, then save your changes.

      • 6. Update your REFRESH TOKEN on Labcollector, and click Update.

      • 7. Test again to see if the problem was resolved.

Useful Links

    2. OAuth 2.0 Google

      • 2. Go to Google Cloud console, and select a project.

      • 3. Then click on “New Project”.

      • 4. Fill the required information.

      • 5. Click on “Create button”, and then wait for the notification.

      • 6. Select the project you just created.

      • 7. Go to APIs & Services and enable the Gmail API.

      • 8. Click on Enable APIs and Services.

      • 9. Search for Gmail API.

      • 10. Enable the API.

      • 11. Now, you need to create Credentials, to do this, click on the CREATE CREDENTIALS.

      • 12. Select User data.

      • 13. Fill the required information from the “OAuth Consent Screen” section, then hit Save and Continue.
      • 14. In the Scope section, you don’t have to do anything, just click Save and Continue.
      • 15. Now, choose the Application Type “Web Application” and enter the Name.

      • 16. Enter the URL path of your Labcollector and complete the URL with /email/get_oauth_token.php
      • 17. Then, add the URL you just created in the Authorized redirect URLs and click on the CREATE.

      • 18. Click Done.
      • 19. Go to Credentials.

      • 20. Click on the name of the client you just created.

      • 21. Copy & Paste:
        • Client ID to “OAUTH CLIENT ID” field Labcollector.
        • Client Secret value to “OAUTH SECRET KEY” field Labcollector.

      • 22. Go to the OAuth consent screen and publish your app or add a Test user.

     

    • LabCollector’s Configuration
      • 1. OAUTH USER EMAIL field could be the same as your email account.
      • 2. OAUTH CLIENT ID field : Google Cloud Console > API’s & Services > Credentials > OAuth 2.0 Client IDs > Click to your client name > Client ID OAUTH 2.0 GOOGLE 10.
      • 3. OAUTH SECRET KEY field : Google Cloud Console > API’s & Services > Credentials > OAuth 2.0 Client IDs > Click to your client name > Client secret.
      • 4. Provider: Google.
      • 5. SMTP: smtp.gmail.com
      • 6. From field: could be the same as your email google account.
      • 7. Click to “Get token” button.
      • 8. Click to your account.

      • 9. Input your Email and Password, then click Next.

      • 10. Accept the permissions to send emails, then click on continue.

      • 11. Click OK, then press the “UPDATE” button.

      • 12. Now, you can test using the button “Send test email”.

    Related topics: