src/eric7/EricNetwork/EricGoogleMailHelpers.py

Thu, 20 Oct 2022 19:19:00 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 20 Oct 2022 19:19:00 +0200
branch
eric7
changeset 9427
905e7af29101
parent 9413
80c06d472826
child 9624
b47dfa7a137d
permissions
-rw-r--r--

Gmail Interface
- changed the Gmail interface to use the Google API packages for authentication (OAuth2) and sending of emails

# -*- coding: utf-8 -*-

# Copyright (c) 2019 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing some helpers for Google mail.
"""

import os

from eric7 import Globals
from eric7.EricWidgets.EricApplication import ericApp

SCOPES = ["https://www.googleapis.com/auth/gmail.send"]
CLIENT_SECRET_FILE = "eric_client_secret.json"  # secok
TOKEN_FILE = "eric_python_email_send_token.json"  # secok
APPLICATION_NAME = "Eric Python Send Email"

RequiredPackages = (
    "google-api-python-client",
    "google-auth-httplib2",
    "google-auth-oauthlib",
)


def isClientSecretFileAvailable():
    """
    Module function to check, if the client secret file has been installed.

    @return flag indicating, that the credentials file is there
    @rtype bool
    """
    return os.path.exists(os.path.join(Globals.getConfigDir(), CLIENT_SECRET_FILE))


def installGoogleAPIPackages():
    """
    Module function to install the required packages to support Google mail.
    """
    pip = ericApp().getObject("Pip")
    pip.installPackages(RequiredPackages, interpreter=Globals.getPythonExecutable())

eric ide

mercurial