Authenticated mail delivery
OAuth2 avoids storing a regular Gmail password in your application.
1. Create a Google project
Create or select a project in Google Cloud Console, configure the consent screen and add the Gmail API.
2. Create OAuth credentials
- Create a Web application OAuth client.
-
Use the OAuth Playground redirect when following the token flow:
https://developers.google.com/oauthplayground. - Add a test user if the consent screen is still in testing mode.
- Record the client ID and client secret securely.
3. Generate a refresh token
- Open Google OAuth Playground.
- Enable Use your own OAuth credentials and enter the client ID/secret.
- Authorize the Gmail scope required by your mail workflow.
- Exchange the authorization code for tokens and copy the refresh token.
4. Configure the admin email settings
Open PUBLIC_URL/video-admin/settings/email. Select
the Gmail/OAuth2 delivery option and enter the sender email,
client ID, client secret and refresh token requested by the form.
Never publish tokens. Treat the refresh token
like a password. Rotate it if it appears in logs, screenshots or a
repository.
5. Send a test email
- Save the email settings.
- Send a password-reset or notification test to a controlled mailbox.
- Check the server log for OAuth scope, sender or token errors.
- Confirm your sender domain and Gmail account are permitted to send the expected volume.