当前位置: 首页>>代码示例>>Python>>正文


Python Credentials.get_by_key_name方法代码示例

本文整理汇总了Python中model.Credentials.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Credentials.get_by_key_name方法的具体用法?Python Credentials.get_by_key_name怎么用?Python Credentials.get_by_key_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Credentials的用法示例。


在下文中一共展示了Credentials.get_by_key_name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import get_by_key_name [as 别名]
 def post(self):
     """Delete the user's credentials from the datastore."""
     urlfetch.fetch(OAUTH2_REVOKE_ENDPOINT % self.credentials.refresh_token)
     util.store_userid(self, '')
     credentials_entity = Credentials.get_by_key_name(self.userid)
     if credentials_entity:
         credentials_entity.delete()
     self.redirect('/')
开发者ID:stigsfoot,项目名称:glassfit,代码行数:10,代码来源:handler.py

示例2: check_auth

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import get_by_key_name [as 别名]
 def check_auth(self, *args):
   self.userid, self.credentials = load_session_credentials(self)
   self.mirror_service = create_service('mirror', 'v1', self.credentials)
   if self.credentials:
     try:
       self.credentials.refresh(httplib2.Http())
       return handler_method(self, *args)
     except AccessTokenRefreshError:
       # Access has been revoked.
       store_userid(self, '')
       credentials_entity = Credentials.get_by_key_name(self.userid)
       if credentials_entity:
         credentials_entity.delete()
   self.redirect('/auth')
开发者ID:jasonsalas,项目名称:WaterLoggforGlass,代码行数:16,代码来源:util.py

示例3: post

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import get_by_key_name [as 别名]
  def post(self):
    """Delete the user's credentials from the datastore."""
    urlfetch.fetch(OAUTH2_REVOKE_ENDPOINT % self.credentials.refresh_token)
    util.store_userid(self, '')

    #clear datastore object for tasklists
    q = TasklistStore.all()
    q.filter("owner = ",self.userid)

    for p in q.run():
      p.delete()

    credentials_entity = Credentials.get_by_key_name(self.userid)
    if credentials_entity:
      credentials_entity.delete()
      
    self.redirect('/')
开发者ID:jbyeung,项目名称:glassgtasks,代码行数:19,代码来源:handler.py

示例4: check_auth

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import get_by_key_name [as 别名]
 def check_auth(self, *args):
     self.userid, self.user_email, self.credentials = load_session_credentials(self)
     self.mirror_service = create_service('mirror', 'v1', self.credentials)
     if self.credentials:
         # validate credentials
         try:
             self.credentials.refresh(httplib2.Http())
             return handler_method(self, *args)
         except AccessTokenRefreshError:
             store_userdetails(self, '', '')
             credentials_entity = Credentials.get_by_key_name(self.userid)
             users_entity = Users.get_by_key_name(key_names=self.user_email)
             if users_entity:
                 users_entity.delete()
             if credentials_entity:
                 credentials_entity.delete()
     self.redirect('/auth')
开发者ID:tikurahul,项目名称:mirror-notify-python-server,代码行数:19,代码来源:util.py

示例5: check_auth

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import get_by_key_name [as 别名]
  def check_auth(self, *args):
    self.userid, self.credentials = load_session_credentials(self)
    self.mirror_service = create_service('mirror', 'v1', self.credentials)



#    http = decorator.http()
#    mePerson = self.user_service.people().get(userId='me').execute(http=http)

    # TODO: Also check that credentials are still valid.
    if self.credentials:
      try:
        self.credentials.refresh(httplib2.Http())
        return handler_method(self, *args)
      except AccessTokenRefreshError:
        # Access has been revoked.
        store_userid(self, '')
        credentials_entity = Credentials.get_by_key_name(self.userid)
        if credentials_entity:
          credentials_entity.delete()
    self.redirect('/auth')
开发者ID:mookiejones,项目名称:Our_Sailing_Family,代码行数:23,代码来源:util.py

示例6: post

# 需要导入模块: from model import Credentials [as 别名]
# 或者: from model.Credentials import get_by_key_name [as 别名]
    def post(self):
        Utilities._init_handler(self)
        if self.empty_query_string('user_email', 'message'):
            self.render('add-to-timeline.html')
        else:
            user_email = self.get_parameter('user_email', None)
            logging.debug('Request Email (%s)' % user_email)
            user_entity = Users.get_by_key_name(key_names=user_email)
            if not user_entity:
                self.add_error('Unknown email address. Have you registered with the service ?')
            else:
                user_id = user_entity.credentials_key
                credentials = StorageByKeyName(Credentials, user_id, 'credentials').get()
                mirror_service = util.create_service('mirror', 'v1', credentials)

                credentials_valid = False
                # make sure credentials are valid
                try:
                    credentials.refresh(httplib2.Http())
                    credentials_valid = True
                except AccessTokenRefreshError:
                    # Access has been revoked.
                    util.store_userdetails(self, '', '')
                    credentials_entity = Credentials.get_by_key_name(self.userid)
                    user_entity_delete = Users.get_by_key_name(key_names=user_email)
                    if credentials_entity:
                        credentials_entity.delete()
                    if user_entity_delete:
                        user_entity_delete.delete()

                if credentials_valid:
                    message = self.get_parameter('message', None)
                    is_html = self.get_parameter('is_html', 'False') == 'True'
                    image_url = self.get_parameter('image_url', None)
                    image = self.get_parameter('image', None)

                    logging.info('Inserting timeline item for (%s)' % user_email)
                    body = {
                        'notification': {'level': 'DEFAULT'},
                        'menuItems': [
                            {'action': 'DELETE'}
                        ]
                    }
                    if is_html:
                        body['html'] = message
                    else:
                        body['text'] = message

                    if image_url:
                        if image_url.startswith('/'):
                            image_url = util.get_full_url(self, image_url)
                        resp = urlfetch.fetch(image_url, deadline=20)
                        media = MediaIoBaseUpload(io.BytesIO(resp.content), mimetype='image/jpeg', resumable=True)
                    elif image:
                        media = MediaIoBaseUpload(io.BytesIO(base64.b64decode(image)), mimetype='image/jpeg')
                    else:
                        media = None

                    # self.mirror_service is initialized in util.auth_required.
                    mirror_service.timeline().insert(body=body, media_body=media).execute()

                    self.add_parameter('success', True)
                    self.add_to_json('success', True)
                    logging.info('Successfully inserted timeline item for (%s)' % user_email)
                else:
                    self.add_error('Revoked Credentials.')

            self.render('add-to-timeline.html')
开发者ID:tikurahul,项目名称:mirror-notify-python-server,代码行数:70,代码来源:main.py


注:本文中的model.Credentials.get_by_key_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。