Пример #1
0
    def __init__(self, channel):
        """
            Constructor

            @param channel: Facebook channel (Row) with API credentials:
                            {app_id=clientID, app_secret=clientSecret}
        """

        from facebook import GraphAPI, GraphAPIError

        self.GraphAPI = GraphAPI
        self.GraphAPIError = GraphAPIError

        request = current.request
        settings = current.deployment_settings

        scope = "email,user_about_me," \
                "user_location,user_photos," \
                "user_relationships,user_birthday,user_website," \
                "create_event,user_events,publish_stream"

        # Set the redirect URI to the default/facebook controller
        redirect_uri = "%s/%s/default/facebook/login" % \
                       (settings.get_base_public_url(), request.application)

        OAuthAccount.__init__(self,
                              client_id = channel.app_id,
                              client_secret = channel.app_secret,
                              auth_url = self.AUTH_URL,
                              token_url = self.TOKEN_URL,
                              scope = scope,
                              redirect_uri = redirect_uri,
                              )
        self.graph = None
Пример #2
0
 def __init__(self):
     OAuthAccount.__init__(self, None, FB_CLIENT_ID, FB_CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='email,user_about_me,user_activities, user_birthday, user_education_history, user_groups, user_hometown, user_interests, user_likes, user_location, user_relationships, user_relationship_details, user_religion_politics, user_subscriptions, user_work_history, user_photos, user_status, user_videos, publish_actions, friends_hometown, friends_location,friends_photos',
                           state="auth_provider=facebook",
                           display='popup')
     self.graph = None
Пример #3
0
    def __init__(self, channel):
        """
            Constructor

            @param channel: dict with Google API credentials:
                            {id=clientID, secret=clientSecret}
        """

        settings = current.deployment_settings

        scope = "https://www.googleapis.com/auth/userinfo.email " \
                "https://www.googleapis.com/auth/userinfo.profile"
        user_agent = "google-api-client-python-plus-cmdline/1.0"

        # Set the redirect URI to the default/google controller
        redirect_uri = "%s/%s/default/google/login" % \
                   (settings.get_base_public_url(), current.request.application)

        OAuthAccount.__init__(self,
                              client_id=channel["id"],
                              client_secret=channel["secret"],
                              auth_url=self.AUTH_URL,
                              token_url=self.TOKEN_URL,
                              scope=scope,
                              user_agent=user_agent,
                              xoauth_displayname=settings.get_system_name(),
                              response_type="code",
                              redirect_uri=redirect_uri,
                              approval_prompt="force",
                              state="google")
        self.graph = None
    def __init__(self, g, db):

        OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET,
                              self.AUTH_URL, self.TOKEN_URL,
                              scope='publish_actions, publish_stream, user_likes')
        self.graph = None
        self.db = db
Пример #5
0
    def __init__(self, channel):
        """
            Args:
                channel: dict with OpenID Connect API parameters:
                            {"auth_url": authURL,
                             "token_url": tokenURL,
                             "userinfo_url": userinfoURL,
                             "id": clientID,
                             "secret": clientSecret,
                             }
        """

        request = current.request
        settings = current.deployment_settings

        scope = "openid profile email"

        # Set the redirect URI to the default/openid_connect controller
        redirect_uri = channel.get("redirect_uri")
        if not redirect_uri:
            redirect_uri = "%s/%s/default/openid_connect" % \
                           (settings.get_base_public_url(), request.application)

        OAuthAccount.__init__(self,
                              client_id=channel["id"],
                              client_secret=channel["secret"],
                              auth_url=channel["auth_url"],
                              token_url=channel["token_url"],
                              scope=scope,
                              response_type="code",
                              redirect_uri=redirect_uri,
                              state="openid_connect")

        self.userinfo_url = channel["userinfo_url"]
        self.graph = None
Пример #6
0
    def __init__(self, channel):
        """
            Constructor

            @param channel: dict with Humanitarian.ID API credentials:
                            {id=clientID, secret=clientSecret}
        """

        request = current.request
        settings = current.deployment_settings

        scope = "profile"

        # Set the redirect URI to the default/humanitarian_id controller
        redirect_uri = "%s/%s/default/humanitarian_id/login" % \
                       (settings.get_base_public_url(), request.application)

        OAuthAccount.__init__(self,
                              client_id=channel["id"],
                              client_secret=channel["secret"],
                              auth_url=self.AUTH_URL,
                              token_url=self.TOKEN_URL,
                              scope=scope,
                              response_type="code",
                              redirect_uri=redirect_uri,
                              state="humanitarian_id")
        self.graph = None
Пример #7
0
 def __init__(self):
     OAuthAccount.__init__(self, None, FB_CLIENT_ID, FB_CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='email',
                           state="auth_provider=facebook",)
                           # display='popup')
     self.graph = None
Пример #8
0
 def __init__(self):
     OAuthAccount.__init__(self, None, FB_CLIENT_ID, FB_CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='public_profile,email',
                           state="auth_provider=facebook",
                           display='popup')
     self.graph = None
Пример #9
0
    def __init__(self, channel):
        """
            Constructor

            @param channel: Facebook channel (Row) with API credentials:
                            {app_id=clientID, app_secret=clientSecret}
        """

        from facebook import GraphAPI, GraphAPIError

        self.GraphAPI = GraphAPI
        self.GraphAPIError = GraphAPIError

        request = current.request
        settings = current.deployment_settings

        scope = "email,user_about_me," \
                "user_location,user_photos," \
                "user_relationships,user_birthday,user_website," \
                "create_event,user_events,publish_stream"

        # Set the redirect URI to the default/facebook controller
        redirect_uri = "%s/%s/default/facebook/login" % \
                       (settings.get_base_public_url(), request.application)

        OAuthAccount.__init__(
            self,
            client_id=channel.app_id,
            client_secret=channel.app_secret,
            auth_url=self.AUTH_URL,
            token_url=self.TOKEN_URL,
            scope=scope,
            redirect_uri=redirect_uri,
        )
        self.graph = None
Пример #10
0
    def __init__(self, g, db):

        OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET,
                              self.AUTH_URL, self.TOKEN_URL,
                              scope='publish_actions, publish_stream, user_likes')
        self.graph = None
        self.db = db
Пример #11
0
    def __init__(self, channel):
        """
            Constructor

            @param channel: dict with Humanitarian.ID API credentials:
                            {id=clientID, secret=clientSecret}
        """

        request = current.request
        settings = current.deployment_settings

        scope = "profile"

        # Set the redirect URI to the default/humanitarian_id controller
        redirect_uri = "%s/%s/default/humanitarian_id/login" % \
                       (settings.get_base_public_url(), request.application)

        OAuthAccount.__init__(self,
                              client_id = channel["id"],
                              client_secret = channel["secret"],
                              auth_url = self.AUTH_URL,
                              token_url = self.TOKEN_URL,
                              scope = scope,
                              response_type = "code",
                              redirect_uri = redirect_uri,
                              state = "humanitarian_id"
                              )
        self.graph = None
Пример #12
0
    def __init__(self, g):

        #import pdb;pdb.set_trace()
        OAuthAccount.__init__(self, g, "248577781948157", "a5abf06a362c8f0fa4cf5da339906185",
                              self.AUTH_URL, self.TOKEN_URL,
                              scope='user_photos,friends_photos')
        self.graph = None
Пример #13
0
 def __init__(self):
     OAuthAccount.__init__(self, None, self.facebook_key, self.facebook_secret,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='email,user_about_me, user_birthday, user_education_history, user_hometown, user_likes, user_location, user_relationships, user_relationship_details, user_religion_politics, user_work_history, user_photos, user_status, user_videos, publish_actions',
                           state="auth_provider=facebook",
                           display='popup')
     self.graph = None
Пример #14
0
    def __init__(self, channel):
        """
            Constructor

            @param channel: dict with Google API credentials:
                            {id=clientID, secret=clientSecret}
        """

        settings = current.deployment_settings

        scope = "https://www.googleapis.com/auth/userinfo.email " \
                "https://www.googleapis.com/auth/userinfo.profile"
        user_agent = "google-api-client-python-plus-cmdline/1.0"

        # Set the redirect URI to the default/google controller
        redirect_uri = "%s/%s/default/google/login" % \
                   (settings.get_base_public_url(), current.request.application)

        OAuthAccount.__init__(self,
                              client_id = channel["id"],
                              client_secret = channel["secret"],
                              auth_url = self.AUTH_URL,
                              token_url = self.TOKEN_URL,
                              scope = scope,
                              user_agent = user_agent,
                              xoauth_displayname = settings.get_system_name(),
                              response_type = "code",
                              redirect_uri = redirect_uri,
                              approval_prompt = "force",
                              state = "google"
                              )
        self.graph = None
Пример #15
0
 def __init__(self):
     OAuthAccount.__init__(self, None,
                             self.google_key,
                             self.google_secret,
                             auth_url=self.AUTH_URL,
                             token_url=self.TOKEN_URL,
 approval_prompt='force', state='auth_provider=google',
 scope='https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email')
Пример #16
0
    def __init__(self):
        with open(os.path.join(request.folder, 'private/google_auth.json'), 'rb') as f:
            gai = Storage(json.load(f)['web'])

        OAuthAccount.__init__(self, None, gai.client_id, gai.client_secret,
                              gai.auth_uri, gai.token_uri,
                              scope='https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
                              approval_prompt='force', state="auth_provider=google")
Пример #17
0
 def __init__(self):
    OAuthAccount.__init__(self,
                          client_id=CLIENT_ID,
                          client_secret=CLIENT_SECRET,
                          auth_url=self.AUTH_URL,
                          token_url=self.TOKEN_URL,
                          scope='manage_pages,read_stream,publish_stream,email,user_photos,friends_photos')
    self.graph = None
Пример #18
0
 def __init__(self):
    OAuthAccount.__init__(self,
                          client_id=CLIENT_ID,
                          client_secret=CLIENT_SECRET,
                          auth_url=self.AUTH_URL,
                          token_url=self.TOKEN_URL,
                          scope='user_photos,friends_photos')
    self.graph = None
Пример #19
0
 def __init__(self):
     OAuthAccount.__init__(self, None, VK_CLIENT_ID, VK_CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='offline',
                           response_type='code',
                           # state="auth_provider=vk",
     )
     self.graph = None
Пример #20
0
 def __init__(self, g):
     OAuthAccount.__init__(self,
                           g,
                           CLIENT_ID,
                           CLIENT_SECRET,
                           self.AUTH_URL,
                           self.TOKEN_URL,
                           scope='user_photos,friends_photos')
     self.graph = None
Пример #21
0
 def __init__(self):
    OAuthAccount.__init__(self,
                          client_id=CLIENT_ID,
                          client_secret=CLIENT_SECRET,
                          auth_url=self.AUTH_URL,
                          token_url=self.TOKEN_URL,
                          scope='email')
    self.graph = None
    self.app_graph = None
Пример #22
0
 def __init__(self):
     OAuthAccount.__init__(
         self,
         client_id - CLIENT_ID,
         client_secret=CLIENT_SECRET,
         auth_url=self.AUTH_URL,
         token_url=self.TOKEN_URL,
         scope="none",
     )
Пример #23
0
 def __init__(self, g):
     OAuthAccount.__init__(
         self,
         g,
         "1081088951917470",
         "ea23cb30c9fabf0a99901ee845161ae5",
         self.AUTH_URL,
         self.TOKEN_URL,
     )
     self.graph = None
Пример #24
0
 def __init__(self):
     OAuthAccount.__init__(self,
                           None,
                           STRAVA_CLIENT_ID,
                           STRAVA_CLIENT_SECRET,
                           self.AUTH_URL,
                           self.TOKEN_URL,
                           response_type='code',
                           approval_prompt='auto'
                           )  # 'force' to force strava auth on every login
     self.client = None
Пример #25
0
 def __init__(self):
     OAuthAccount.__init__(
         self,
         client_id=self.client_id,
         client_secret=self.client_secret,
         auth_url=self.AUTH_URL,
         token_url=self.TOKEN_URL,
         approval_prompt='force',
         state='auth_provider=google',
         scope=
         'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/youtube.upload'
     )
Пример #26
0
 def __init__(self):
     OAuthAccount.__init__(
         self,
         client_id=myconf.get('client.id'),
         client_secret=myconf.get('client.secret'),
         auth_url=self.AUTH_URL,
         token_url=self.TOKEN_URL,
         approval_prompt='force',
         state='auth_provider=google',
         scope=
         'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
     )
Пример #27
0
 def __init__(self, db):
     self.db = db
     g = dict(GraphAPI=GraphAPI,
              GraphAPIError=GraphAPIError,
              request=current.request,
              response=current.response,
              session=current.session,
              HTTP=HTTP)
     client = dict(db.config.get_list('auth', 'facebook'))
     OAuthAccount.__init__(self, g, client['id'], client['secret'],
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='email,user_about_me,user_location,user_photos,user_relationships,user_birthday,user_website,create_event,user_events,publish_stream')
     self.graph = None
Пример #28
0
    def __init__(self):
        OAuthAccount.__init__(self, 
                              g=globals(),
                              client_id=CLIENT_ID,
                              client_secret=CLIENT_SECRET,
                              auth_url=self.AUTH_URL,
                              token_url=self.TOKEN_URL,
                              redirect_uri=REDIRECT_URI,
                              state=os.urandom(16).encode('hex'),
                                  # random string to detect cross-site request forgery
                              scope='public_repo')  # add ',repo' if including private repos

        # adding session here, since older OAuthAccount doesn't seem to have it.. :-/
        self.session = globals()['session']
Пример #29
0
    def __init__(self):
        OAuthAccount.__init__(self, 
                              g=globals(),
                              client_id=CLIENT_ID,
                              client_secret=CLIENT_SECRET,
                              auth_url=self.AUTH_URL,
                              token_url=self.TOKEN_URL,
                              redirect_uri=REDIRECT_URI,
                              state=os.urandom(16).encode('hex'),
                                  # random string to detect cross-site request forgery
                              scope='public_repo')  # add ',repo' if including private repos

        # adding session here, since older OAuthAccount doesn't seem to have it.. :-/
        self.session = globals()['session']
Пример #30
0
Файл: db.py Проект: kwmcc/IDEal
    def __init__(self):
        with open(os.path.join(request.folder, 'private/google_auth.json'),
                  'rb') as f:
            gai = Storage(json.load(f)['web'])

        OAuthAccount.__init__(
            self,
            None,
            gai.client_id,
            gai.client_secret,
            gai.auth_uri,
            gai.token_uri,
            scope=
            'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
            approval_prompt='force',
            state="auth_provider=google")
Пример #31
0
        def __init__(self, g=globals()):
            OAuthAccount.__init__(self,
                                  g,
                                  client_id=cl_id,
                                  client_secret=cl_secret,
                                  auth_url=self.auth_url,
                                  token_url=self.token_url,
                                  state='xyz')

            def get_user(self):
                token = self.accessToken()
                if not token:
                    return None

                uri = config.get("OAUTH_CONF", "resource_url")
                r = requests.get(uri, params={'access_token': token})
                userdata = r.json()
                user_info = {}
                if ' ' in userdata['name']:
                    #user_info['first_name'],user_info['middle_name'],user_info['last_name']=userdata['name'].split()
                    data = userdata['name'].split()
                    if len(data) > 2:
                        user_info['first_name'] = data[0]
                        user_info['middle_name'] = data[1]
                        user_info['last_name'] = data[2]
                    else:
                        user_info['first_name'] = data[0]
                        user_info['last_name'] = data[1]
                else:
                    user_info['first_name'] = userdata['name']
                    user_info['last_name'] = ' '

                user_info['user_name'] = userdata['user_id']
                user_info['email'] = userdata['email']

                user_info['roles'] = fetch_user_role(user_info['user_name'])
                # If user has super admin rights; it is added to separate organization
                if current.ADMIN in user_info['roles']:
                    user_info['organisation'] = 'ADMIN'
                else:
                    user_info['organisation'] = 'IITD'
                create_or_update_user(user_info, False)
                return dict(first_name=user_info['first_name'],
                            last_name=user_info['last_name'],
                            email=userdata['email'],
                            username=userdata['user_id'])
Пример #32
0
    def __init__(self, channel):

        from facebook import GraphAPI, GraphAPIError

        self.GraphAPI = GraphAPI
        self.GraphAPIError = GraphAPIError
        g = dict(GraphAPI=GraphAPI,
                 GraphAPIError=GraphAPIError,
                 request=current.request,
                 response=current.response,
                 session=current.session,
                 HTTP=HTTP)

        OAuthAccount.__init__(self, g, channel.app_id, channel.app_secret,
                              self.AUTH_URL, self.TOKEN_URL,
                              scope="email,user_about_me,user_location,user_photos,user_relationships,user_birthday,user_website,create_event,user_events,publish_stream")
        self.graph = None
Пример #33
0
 def __init__(self, db):
     self.db = db
     g = dict(GraphAPI=GraphAPI,
              GraphAPIError=GraphAPIError,
              request=current.request,
              response=current.response,
              session=current.session,
              HTTP=HTTP)
     client = dict(db.config.get_list('auth', 'facebook'))
     OAuthAccount.__init__(
         self,
         g,
         client['id'],
         client['secret'],
         self.AUTH_URL,
         self.TOKEN_URL,
         scope=
         'email,user_about_me,user_location,user_photos,user_relationships,user_birthday,user_website,create_event,user_events,publish_stream'
     )
     self.graph = None
Пример #34
0
     def __init__(self,g=globals()):
         OAuthAccount.__init__(self,g,client_id=cl_id,client_secret=cl_secret,auth_url=self.auth_url,token_url=self.token_url,state='xyz')
      
         def get_user(self):
             token=self.accessToken()
             if not token:
                 return None
             
             uri=config.get("OAUTH_CONF","resource_url")
             r=requests.get(uri,params={'access_token':token})
             userdata=r.json()
             user_info={}
             if ' ' in userdata['name']:
                 #user_info['first_name'],user_info['middle_name'],user_info['last_name']=userdata['name'].split()
                 data=userdata['name'].split()
                 if len(data) > 2:
                     user_info['first_name']=data[0]
                     user_info['middle_name']=data[1]
                     user_info['last_name']=data[2]
                 else:
                     user_info['first_name']=data[0]
                     user_info['last_name']=data[1]
             else: 
                 user_info['first_name']=userdata['name']
                 user_info['last_name']=' '
 
             user_info['user_name'] = userdata['user_id']
             user_info['email'] = userdata['email']
 
             user_info['roles'] = fetch_user_role(user_info['user_name'])
             # If user has super admin rights; it is added to separate organization
             if current.ADMIN in user_info['roles']:
                 user_info['organisation'] = 'ADMIN'
             else:
                 user_info['organisation'] = 'IITD'
             create_or_update_user(user_info, False) 
             return dict(first_name=user_info['first_name'],last_name=user_info['last_name'],email=userdata['email'],username = userdata['user_id'] )
Пример #35
0
 def __init__(self, g):
     OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='user_photos,friends_photos')
     self.graph = None
Пример #36
0
 def __init__(self,g):
     OAuthAccount.__init__(self,g,CLIENT_ID,CLIENT_SECRET,self.AUTH_URL,self.TOKEN_URL,
         scope='public_profile,email')
     self.graph=None
Пример #37
0
 def __init__(self,g=globals()):
     OAuthAccount.__init__(self,g,client_id=cl_id,client_secret=cl_secret,auth_url=self.auth_url,token_url=self.token_url,state='xyz')
Пример #38
0
 def __init__(self, g):
     OAuthAccount.__init__(self, g, "231547190343989", "05003c7c704ca6d524fbd84ac0a1dd46",
                           self.AUTH_URL, self.TOKEN_URL,
                           )
     self.graph = None
Пример #39
0
 def __init__(self):
     OAuthAccount.__init__(self, None, STRAVA_CLIENT_ID, STRAVA_CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           response_type='code',
                           approval_prompt='auto') # 'force' to force strava auth on every login
     self.client = None
Пример #40
0
 def __init__(self):        
     OAuthAccount.__init__(self, None, self.twitter_key, self.twitter_secret, self.AUTH_URL, self.TOKEN_URL)
Пример #41
0
 def __init__(self):
     OAuthAccount.__init__(self,client_id-CLIENT_ID,client_secret=CLIENT_SECRET,auth_url=self.AUTH_URL,token_url=self.TOKEN_URL,scope='none')
Пример #42
0
 def __init__(self):
     OAuthAccount.__init__(self, None, FB_CLIENT_ID, FB_CLIENT_SECRET,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='email, user_about_me, user_birthday, user_status, publish_actions',
                           state="auth_provider=facebook")
     self.graph = None
Пример #43
0
 def __init__(self):
     OAuthAccount.__init__(self, 'linkedin', self.linkedin_key, self.linkedin_secret,
                           self.AUTH_URL, self.TOKEN_URL,
                           scope='r_emailaddress',
                           state=self._make_new_state())