11

Google APIs python 客户端对 Django 有特殊的支持,在 Google ( https://developers.google.com/api-client-library/python/guide/django ) 给出的示例中,类 oauth2client.django_orm.Storage 是用于存储和检索 Credentials 对象。

但是,我找到了很多示例(https://github.com/jgmize/django-google-drive/tree/master/gdrive/gdoauth2https://github.com/praekelt/django-google-credentials/tree/ master/google_credentials等)将 Credentials 放入用户个人资料的 CredentialsField 字段中,并将其保存到数据库中。

这两种方法的优点/缺点是什么?有偏好吗?

谢谢。

4

1 回答 1

1

要使用 google 功能实现登录,您可以使用django-allauth https://django-allauth.readthedocs.io/en/latest/

它提供了易于集成的 Django 应用程序集,可解决身份验证、注册、帐户管理以及第 3 方(社交)帐户身份验证。

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

于 2020-12-06T12:10:53.127 回答