Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to store google oauth token in django : Storage or database

The Google APIs python client has special support for the Django and in the examples given by Google (https://developers.google.com/api-client-library/python/guide/django), the class oauth2client.django_orm.Storage is used to store and retrieve Credentials objects.

However, I find lots of examples (https://github.com/jgmize/django-google-drive/tree/master/gdrive/gdoauth2, https://github.com/praekelt/django-google-credentials/tree/master/google_credentials ,etc) put the Credentials in a CredentialsField field of the user's profile,and it is saved into the database.

What are the advantages / disadvantages of the two methods ? Are there preferences ?

Thanx.

like image 430
yunshi Avatar asked Oct 13 '14 20:10

yunshi


1 Answers

To implementsign in with google feature you can use django-allauth https://django-allauth.readthedocs.io/en/latest/

it provides easy to integrate set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

https://django-allauth.readthedocs.io/en/latest/providers.html#google

like image 137
Gr8ayu Avatar answered Nov 05 '22 05:11

Gr8ayu