Source

django-publicauth / publicauth / backends / google.py

offline 71953ab 

















from __future__ import absolute_import

from openid.extensions.ax import FetchRequest, AttrInfo, FetchResponse

from publicauth.backends.openid import OpenIDBackend
from publicauth import settings


class GoogleBackend(OpenIDBackend):
    
    def get_extra_data(self, resp):
        return FetchResponse.fromSuccessResponse(resp)

    def extract_data(self, data, field):
        try:
            return {self.PROFILE_MAPPING[field][0]: data.getSingle(settings.AX_URIS[field], '')}
        except:
            return {self.PROFILE_MAPPING[field]: ''}