コード例 #1
0
ファイル: util.py プロジェクト: Foton512/dognet
def getSocialUrlByUser(user):
    try:
        socialUser = DjangoUserMixin.get_social_auth_for_user(user)[0]
        if socialUser.provider == "vk-oauth2":
            return "vk.com/id{}".format(socialUser.uid)
            # TODO: Add facebook
    except:
        return None
コード例 #2
0
ファイル: oauth.py プロジェクト: vhf/blaggregator
def update_user_details(hacker_id, user):
    social_auth = DjangoUserMixin.get_social_auth_for_user(user)[0]
    backend = social_auth.get_backend_instance()
    social_auth.refresh_token(DjangoStrategy())
    url = backend.HACKER_SCHOOL_ROOT + '/api/v1/people/%s?' % hacker_id + urlencode({
        'access_token': social_auth.extra_data['access_token']
    })

    try:
        response = backend.request(url, method='GET')
        hacker_data = backend.get_user_details(response.json())
        create_or_update_hacker(None, hacker_data, None, User.objects.get(id=hacker_id))

    except Exception:
        # It's not very bad, if we are not able to update the userdata... we
        # silently ignore it.
        pass
コード例 #3
0
ファイル: oauth.py プロジェクト: vhf/blaggregator
def update_user_details(hacker_id, user):
    social_auth = DjangoUserMixin.get_social_auth_for_user(user)[0]
    backend = social_auth.get_backend_instance()
    social_auth.refresh_token(DjangoStrategy())
    url = backend.HACKER_SCHOOL_ROOT + '/api/v1/people/%s?' % hacker_id + urlencode(
        {'access_token': social_auth.extra_data['access_token']})

    try:
        response = backend.request(url, method='GET')
        hacker_data = backend.get_user_details(response.json())
        create_or_update_hacker(None, hacker_data, None,
                                User.objects.get(id=hacker_id))

    except Exception:
        # It's not very bad, if we are not able to update the userdata... we
        # silently ignore it.
        pass