Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMail OAuth2 Support (gmail://) #1250

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

caronc
Copy link
Owner

@caronc caronc commented Dec 8, 2024

Description:

Related issue (if applicable): #365

GMail OAuth support to be added in this PR

Starting January 2025, Google plans to discontinue the use of app passwords, which have traditionally allowed less secure apps to access Gmail accounts. This change enhances account security but affects methods like using Python's smtplib with app passwords to send emails. To continue sending emails via Gmail using Python, you'll need to adopt more secure authentication methods, such as OAuth 2.0.

Account Setup

Set Up a Google Cloud Project

  1. Visit the Google Cloud Console.
  2. Create a new project.
  3. Enable the Gmail API for your project.
    1. Navigate to Enable API's & services
    2. Search for Gmail API and chose the Enable button after you access it.
    3. Click on Create Credentials (top right)
    4. Select User Data as the Data Access Type
  4. Configure OAuth Consent Screen:
    1. Be sure to set up the Credential Type as External
    2. Navigate to APIs & Services > OAuth consent screen (located on the left hand side).
    3. Add the gmail.send (https://www.googleapis.com/auth/gmail.send (Sensitive Scope) to your project.
    4. Add your email to the Test Users section.
  5. Create OAuth 2.0 Credentials:
    1. Navigate to APIs & Services > Credentials.
    2. Click Create Credentials > OAuth 2.0 Client ID.
    3. For the Application Type, choose Desktop App
    4. Fill out the details as required and click Create
Notes:
  • When the app is in testing mode (not published), you must explicitly add the email address of your test user.

    1. Go to APIs & Services > OAuth Consent Screen.
    2. Add the email address under the Test Users section.

    Test users only need to be added in testing mode.
    If the app is published, test users are no longer required.

New Service Completion Status

  • apprise/plugins/gmail.py
  • KEYWORDS
    • add new service into this file (alphabetically).
  • README.md
    • add entry for new service to table (as a quick reference)
  • packaging/redhat/python-apprise.spec
    • add new service into the %global common_description

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@365-gmail-oauth2-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  'gmail://gmailuser@client_id/client_secret/`

@caronc caronc changed the title gmail oauth support initial commit GMail OAuth2 Support (gmail://) Dec 8, 2024
@caronc caronc force-pushed the 365-gmail-oauth2-support branch from e731e12 to d508c93 Compare December 15, 2024 18:09
Copy link

codecov bot commented Dec 15, 2024

Codecov Report

Attention: Patch coverage is 18.14815% with 221 lines in your changes missing coverage. Please review.

Project coverage is 98.32%. Comparing base (551fa0d) to head (10dcb0b).

Files with missing lines Patch % Lines
apprise/plugins/gmail.py 17.04% 219 Missing ⚠️
apprise/logger.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1250      +/-   ##
==========================================
- Coverage   99.36%   98.32%   -1.05%     
==========================================
  Files         159      160       +1     
  Lines       20687    20957     +270     
  Branches     3715     3774      +59     
==========================================
+ Hits        20556    20605      +49     
- Misses        121      342     +221     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants