D
D
Dmitry Vyatkin2016-02-17 04:45:47
Django
Dmitry Vyatkin, 2016-02-17 04:45:47

Python-social-auth how to get country and other user information?

Good afternoon! Tell me how to get user information from the VK API via python-social-auth, I add
"SOCIAL_AUTH_VK_OAUTH2_SCOPE = ['country']" to settings,
but I can't get it in my pipeline.

def create_user(strategy, details, backend, uid, user=None, *args, **kwargs):
    strategy.provider = 'vk'
    try:
        get_user = User.objects.get(username=uid)
    except User.DoesNotExist:
        get_user = None
    if get_user:
        return {
            'is_new': False,
            'user': get_user,
        }
    else:
        user = User.objects.create(
            username=uid,
            first_name=details['first_name'],
            last_name=details['last_name'],
            is_staff=True,
            is_active=True,
        )
    return {
        'is_new': True,
        'user': user,
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question