I want to save phone number when signin with GOOGLE_OAUTH2, for that I set the following settings -
SOCIAL_AUTH_GOOGLE_OAUTH2_IGNORE_DEFAULT_AX_ATTRS = True
SOCIAL_AUTH_GOOGLE_OAUTH2_AX_SCHEMA_ATTRS = [
('phonenumber', 'phonenumber')
]
SOCIAL_AUTH_GOOGLE_OAUTH2_IGNORE_DEFAULT_SCOPE = True
SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = [
'https://www.googleapis.com/auth/plus.login',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/user.phonenumbers.read',
]
for pipelines -
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.social_auth.associate_by_email',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
'accounts.pipelines.demo_pipeline',
)
in pipelines.py
def demo_pipeline(backend, details, response, *args, **kwargs):
print(dict(backend.get_user_details(response), **details))
print(kwargs)
print(args)
print(response)
print(details)
by the print statements I am trying to see the phonenumeber but phonenumber is not in any of them, it prints -
{'first_name': 'Vikash', 'email': 'vikash.ch120@gmail.com', 'fullname': 'Vikash chaudhary', 'username': 'vikash.ch120', 'last_name': 'chaudhary'}
{'new_association': True, 'request': <AsgiRequest: GET '/oauth/complete/google-oauth2/?state=ogEhGag7Awmo0d2t9UruAGNuxQwZClGq&code=4/uAGpCv3mpSKzDnwYbZjhn39uOTe6ysYjN0ybJaukLiUo7aMRVSx8SWrnAz7IUZpl-Vps1DzQ4qgewgR8O0Z0XBU&scope=email+profile+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/user.phonenumbers.read&authuser=0&session_state=138e7b111722948cadba63fe63b20db5bd036801..a701&prompt=none'>, 'strategy': <social_django.strategy.DjangoStrategy object at 0x000002A0E0693780>, 'social': <UserSocialAuth: vikash.ch120@gmail.com>, 'pipeline_index': 10, 'username': 'vikash.ch120', 'user': <User: vikash.ch120@gmail.com>, 'storage': <class 'social_django.models.DjangoStorage'>, 'is_new': True, 'uid': 'vikash.ch120@gmail.com'}
()
{'access_token': 'ya29.ImW0B1jqyIaKlz-YTU85Ana3ggCb9jFSdBHf15WilEwlOYmjcQBvjvmmFsLYbDtPRz_k2Lv6hzixwF_H4gcjOSZkMaLpgsT5tKBwqzEGQ-OaxzMnC9p_AcUfe1vzmQK7J0byx6J_aA', 'sub': '113443706233393763678', 'given_name': 'Vikash', 'email': 'vikash.ch120@gmail.com', 'family_name': 'chaudhary', 'picture': 'https://lh3.googleusercontent.com/-YAzJ9fQQVHI/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rdnxxIBtM0_TxffVU_Lrt0o2cYO6g/photo.jpg', 'locale': 'en', 'token_type': 'Bearer', 'email_verified': True, 'expires_in': 3599, 'name': 'Vikash chaudhary', 'scope': 'https://www.googleapis.com/auth/user.phonenumbers.read openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 'id_token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6IjViNWRkOWJlNDBiNWUxY2YxMjFlMzU3M2M4ZTQ5ZjEyNTI3MTgzZDMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXpwIjoiNjgzODY4OTU2NzM1LXBkaWczYXI2cTUxdXZudmZrZ2hodGpmNW1kc2tubDg2LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiNjgzODY4OTU2NzM1LXBkaWczYXI2cTUxdXZudmZrZ2hodGpmNW1kc2tubDg2LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTEzNDQzNzA2MjMzMzkzNzYzNjc4IiwiZW1haWwiOiJ2aWthc2guY2gxMjBAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiJGanJHZzZKTmN6OXhKQkx5X0lPXzZBIiwiaWF0IjoxNTc1NzUzNTYzLCJleHAiOjE1NzU3NTcxNjN9.w_VlokapGAs52NhjSft36lz_xhNC95m2W6HPN4FxZ8x-iG-rs6LlfCkbej8uq6zsve3qZJvco4KCQmPZUSMebk8mf3t_S9cWLHupifZDFb7nHqhW3w7R_DfZ-N6MmVoikhGtpEq2nHIcHwB1zKlQ21u7cJ8nHvcltrgCO9iXBOq18rNobfHAG1yxZaqqJg_OsvXUN5AYhxDdRq2nzMvAbj1vuq7J1h5FpDjuEusWrwwYHDZ5lnqw0mYkfpfK1zVzr9ZIK8QfyXXNDTvj8bML5LMFLL-f0hku5d73OCC7QeeffRvK411V55vs0nC0zkOYN-lqLR3DXm7gkGGGPzHiNw'}
{'fullname': 'Vikash chaudhary', 'first_name': 'Vikash', 'username': 'vikash.ch120', 'last_name': 'chaudhary', 'email': 'vikash.ch120@gmail.com'}
I followed the documentation configuration -
In Google Authentication page it is asking to permit view phone numbers
but in response I am not getting the phone number, what mistake I am doing ?