【问题标题】:django-allauth not saving google extra datadjango-allauth 不保存谷歌额外数据
【发布时间】:2021-07-31 00:04:30
【问题描述】:

我的settings.py 是这样的

# other settings

SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'SCOPE': [
            'email',
            'public_profile',
            'user_friends',
            'user_gender',
            'user_birthday',
            'user_location',
            'user_link',
            'user_age_range',
        ],
        'FIELDS': [
            'id',
            'first_name',
            'last_name',
            'middle_name',
            'name',
            'short_name',
            'name_format',
            'gender',
            'birthday',
            'age_range',
            'friends',
            'location',
            'picture',
            'link',
        ],
        'EXCHANGE_TOKEN': True,
        'VERIFIED_EMAIL': False,
        'VERSION': 'v7.0',
    },
    'google': {
        'SCOPE': [
            'https://www.googleapis.com/auth/userinfo.profile',
            'https://www.googleapis.com/auth/userinfo.email',
            'https://www.googleapis.com/auth/user.emails.read',
            'https://www.googleapis.com/auth/user.phonenumbers.read',
            'https://www.googleapis.com/auth/user.birthday.read',
            'https://www.googleapis.com/auth/profile.agerange.read',
            'https://www.googleapis.com/auth/user.addresses.read',
        ],
        'AUTH_PARAMS': {
            'access_type': 'online',
        }
    }
}

使用 facebook 可以正常工作,我在那里得到了我想要的,但是使用 google 签名时一切正常(请求权限.. 一切都会进行)它会进行身份验证用户并将其保存在 db 上,但在 extra data 字段上我只是得到

{
  "id": "...",
  "email": "...",
  "verified_email": true,
  "name": "..",
  "given_name": "..",
  "picture": "..",
  "locale": "en"
}

那么生日性别地址年龄范围和其他字段会发生什么变化。

【问题讨论】:

    标签: python django google-oauth django-allauth


    【解决方案1】:

    生日、性别、地址、年龄范围等数据保护字段通常默认设置为私人。因此,外部 API 访问仅限于该给定用户的公共字段。

    例如,生日:

    如果您访问自己帐户的birthday。您会注意到它可能设置为 'Only Me',表示它已设置为私人。

    为了访问您被限制访问的所有字段,您必须更改所有组件的此配置文件配置,使其成为公共

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-02
      • 2019-01-19
      • 2016-02-10
      • 1970-01-01
      • 2016-08-15
      • 2021-12-31
      • 1970-01-01
      • 2014-12-02
      相关资源
      最近更新 更多