Skip to content

Simplifies Gmail authentication for Django applications using OAuth 2.0. WITHOUT App Passwords!

License

Notifications You must be signed in to change notification settings

yeongbin-jo/django-gmail-oauth-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-gmail-oauth-backend

Simplifies Gmail authentication for Django applications using OAuth 2.0. WITHOUT App Passwords!

Installation

pip install django-gmail-oauth-backend

Add settings to your Django project settings file.

GMAIL_OAUTH_CLIENT_ID = 'YOUR_CLIENT_ID'
GMAIL_OAUTH_CLIENT_SECRET = 'YOUR_CLIENT_SECRET'

INSTALLED_APPS = [
    ...,
    'gmail_oauth_backend',
    ...
]

And execute the following command at least once initially. This command will launch a web browser and request OAuth approval through the user’s browser. Once the request is completed, a Refresh Token for the Gmail API will be automatically issued. Before running this init command, please make sure to add http://localhost:8912/ to the redirect URLs in your Cloud Console settings.

# Create RefreshToken table First
./manage.py migrate

# Then get the RefreshToken
./manage.py init_gmail_oauth_token

Note: The Refresh Token is stored in the database and is used to automatically refresh the Access Token when it expires. The Google OAuth 2.0 refresh token typically does not have an expiration date, but if a refresh token becomes invalid or expires for other reasons, it will need to be reissued following the procedure above.

Credits

Authors & Contributors

About

Simplifies Gmail authentication for Django applications using OAuth 2.0. WITHOUT App Passwords!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages