๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
Book a DemoInstallSign in
Socket

django-oauth-emailbackend

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-oauth-emailbackend

Django emailbackend that using OAuth Gmail API or SMTP server.

0.1.6
PyPI
Maintainers
1

django-oauth-emailbackend

Django emailbackend that using OAuth Gmail API or SMTP server.

Installation

First, install the python package.

pip install django-oauth-emailbackend

Then, add the following to the settings.py of your project:

INSTALLED_APPS = [
    ...
    'django.contrib.sites',
    'oauth_emailbackend',
    ...
]

#----- django-oauth-emailbackend settings -----#
# EMAIL_BACKEND๋ฅผ OAuthEmailBackend ์„ค์ • 
# Celery๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐœ์†กํ•˜๋Š” ๊ฒฝ์šฐ CELERY_BROKER_URL ๊ฐ’์„ ์„ค์ •ํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
EMAIL_BACKEND                = 'oauth_emailbackend.backends.OAuthEmailBackend'

# ๋ฐœ์†ก๋‚ด์—ญ์„ ์ €์žฅํ•  DATABASE_NAME
OAUTH_EMAILCLIENT_DBNAME     = 'default'

# OAuth ๋ชฉ๋ก 
OAUTH_EMAILBACKEND_PROVIDERS = (
    'oauth_emailbackend.providers.gmail',
)
# ์ฝœ๋ฐฑ ๋„๋ฉ”์ธ์„ ํ˜„์žฌ ์‚ฌ์ดํŠธ ๋„๋ฉ”์ธ๊ณผ ๋‹ค๋ฅด๊ฒŒ ์ง€์ •ํ•˜๋ ค๋ฉด ์„ค์ •. ์˜ˆ) https://domain.to
OAUTH_EMAILBACKEND_CALLBACK_HOST    = None
OAUTH_EMAILBACKEND_USE_CELERY       = True
OAUTH_EMAILBACKEND_CELERY_MAX_RETRY = 3 # default=3
# OS SMTP server name
OAUTH_EMAILBACKEND_MTA              = 'postfix' # [None|postfix]


#----- celery settings -----#
# Celery๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐœ์†กํ•  ๊ฒฝ์šฐ CELERY_BROKER_URL ์„ธํŒ… 
CELERY_BROKER_URL = "<broker url for celery>"
#
# * Test run celery in localhost
# celery -A config worker -l info -E

Additionally, add this to your project urls.py:

urlpatterns = [
    ...
    # Add OAuth Emailbackend urls
    path('oauth_emailbackend/', include('oauth_emailbackend.urls')),
    ...
]

Post-Installation

In your Django root execute the command below to create your database tables:

python manage.py migrate

Register API client on the admin page

Visit https://<host>/admin/oauth_emailbackend/oauthapi/ and add OAuth API and Email Client app sequentially.

Test

from django.core.mail import send_mail

send_mail("Subject here",  
            "Here is the message.", 
            "<sender-email-address>", 
            ["<recipient-email-address>"],
            fail_silently=False)

Providers

Gmail

  • https://developers.google.com/gmail/api/guides
  • https://console.cloud.google.com/ API ๊ฐœ์„ค
  • ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด ์—์„œ OAuth 2.0 ํด๋ผ์ด์–ธํŠธ ID ์ƒ์„ฑ
  • OAuth ๋™์˜ ํ™”๋ฉด ๊ตฌ์„ฑ
  • ์Šน์ธ๋œ ๋ฆฌ๋””๋ ‰์…˜ URI์—๋Š” https://<host>/oauth_emailbackend/oauth2callback/gmail์„ ์ž…๋ ฅ

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts