Gmail Setup (oAuth2)
Gmail service mail configuration via OAuth2 Authentication
Google Account Settings












Settings in MikoPBX






Troubleshooting


Last updated
Was this helpful?
Gmail service mail configuration via OAuth2 Authentication
Setting up OAuth 2.0 in Google requires using the station's URL address.
The easiest way is to create a DNS record on the local server or add an IP address-to-domain name mapping in the hosts file on the device from which the configuration is being performed.
Before starting the setup, you need to change some Google account parameters. To do this, go to the account management page (link).

Go to the "Security and sign-in" section. Make sure that two-step authentication is configured.

Go to the Google Cloud Console, to the "APIs & Services" section (link). Create a project for the current task.

Go to the APIs library (the "Library" section).

Enter "gmail api" in the search bar. Open the Gmail API card.

Click "Enable" to connect.

Go to the main APIs & Services page. Then click "OAuth consent screen".

Create a project (click "Get started"). Fill in an arbitrary name and your email. Select "Internal" as the Audience. Click "Create" to finish.

Return to the main APIs & Services page. Then go to the "Credentials" section. Click "Create credentials". Select "OAuth client ID" to create.

Select "Web application" as the Application type. Then enter an arbitrary name. Click "Create".

Add a new "Authorized redirect URI".
Format:
https://mikopbx.station.com/pbxcore/api/v3/mail-settings/oauth2-callback
Replace "mikopbx.station.com" with your station's URL.

An OAuth client will be created. Save the Client ID and Client Secret to your notes. You will need this data for the connection in the future.

Go to the "System" -> "Mail and notifications" section:

Next, go to "SMTP Settings". Fill in the following parameters:
Sender address, Sender name — your email and the name from which the emails will be sent.
Authentication type — OAuth2.
SMTP login — your email.
OAuth2 Provider — Google/Gmail.
Application ID (Client ID), Secret key (Client Secret) — the data saved from Google Cloud (step 12 from the previous section of this guide).
Leave all other settings at their default values. A more detailed description can be found in the main article about mail parameters (link).
After that, click "Save"!

Click the blue "Connect via OAuth2" button. Then select your Gmail account.

Confirm the sign-in: click "Continue".

Confirm granting the required permissions (click "Allow").

Upon successful authorization, you will see the following window.

Access blocked: Authorization Error (**Error 400: invalid_request)

Solution: enter the station's URL address in the MikoPBX web interface: "Network and Firewall" -> "Network Interfaces". Go to the "Network Topology" section and enter the hostname in the "External hostname of your router" field. (Enable "This station is located behind a NAT router".)

Last updated
Was this helpful?
Was this helpful?

