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


Python token.OAuth2Client类代码示例

本文整理汇总了Python中r2.models.token.OAuth2Client的典型用法代码示例。如果您正苦于以下问题:Python OAuth2Client类的具体用法?Python OAuth2Client怎么用?Python OAuth2Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: delete

    def delete(self, delete_message=None):
        self.delete_message = delete_message
        self._deleted = True
        self._commit()

        #update caches
        Account._by_name(self.name, allow_deleted = True, _update = True)
        #we need to catch an exception here since it will have been
        #recently deleted
        try:
            Account._by_name(self.name, _update = True)
        except NotFound:
            pass
        
        #remove from friends lists
        q = Friend._query(Friend.c._thing2_id == self._id,
                          Friend.c._name == 'friend',
                          eager_load = True)
        for f in q:
            f._thing1.remove_friend(f._thing2)

        q = Friend._query(Friend.c._thing2_id == self._id,
                          Friend.c._name == 'enemy',
                          eager_load=True)
        for f in q:
            f._thing1.remove_enemy(f._thing2)

        # Remove OAuth2Client developer permissions.  This will delete any
        # clients for which this account is the sole developer.
        from r2.models.token import OAuth2Client
        for client in OAuth2Client._by_developer(self):
            client.remove_developer(self)
开发者ID:Oddman,项目名称:reddit,代码行数:32,代码来源:account.py

示例2: delete

    def delete(self, delete_message=None):
        self.delete_message = delete_message
        self.delete_time = datetime.now(g.tz)
        self._deleted = True
        self._commit()

        # update caches
        Account._by_name(self.name, allow_deleted=True, _update=True)
        # we need to catch an exception here since it will have been
        # recently deleted
        try:
            Account._by_name(self.name, _update=True)
        except NotFound:
            pass

        # remove from friends lists
        q = Friend._query(Friend.c._thing2_id == self._id, Friend.c._name == "friend", eager_load=True)
        for f in q:
            f._thing1.remove_friend(f._thing2)

        q = Friend._query(Friend.c._thing2_id == self._id, Friend.c._name == "enemy", eager_load=True)
        for f in q:
            f._thing1.remove_enemy(f._thing2)

        # wipe out stored password data after a recovery period
        TryLater.schedule("account_deletion", self._id36, delay=timedelta(days=90))

        # Remove OAuth2Client developer permissions.  This will delete any
        # clients for which this account is the sole developer.
        from r2.models.token import OAuth2Client

        for client in OAuth2Client._by_developer(self):
            client.remove_developer(self)
开发者ID:pombredanne,项目名称:reddit,代码行数:33,代码来源:account.py

示例3: run

    def run(self, client_id):
        if not client_id:
            return self.error()

        client = OAuth2Client.get_token(client_id)
        if client:
            return client
        else:
            return self.error()
开发者ID:ArslanRafique,项目名称:reddit,代码行数:9,代码来源:oauth2.py

示例4: _get_client_auth

 def _get_client_auth(self):
     auth = request.headers.get("Authorization")
     try:
         client_id, client_secret = parse_http_basic(auth)
         client = OAuth2Client.get_token(client_id)
         require(client)
         require(constant_time_compare(client.secret, client_secret))
         return client
     except RequirementException:
         abort(401, headers=[("WWW-Authenticate", 'Basic realm="reddit"')])
开发者ID:Bebetz,项目名称:reddit,代码行数:10,代码来源:oauth2.py

示例5: _get_client_auth

 def _get_client_auth(self):
     auth = request.headers.get("Authorization")
     try:
         auth_scheme, auth_token = require_split(auth, 2)
         require(auth_scheme.lower() == "basic")
         try:
             auth_data = base64.b64decode(auth_token)
         except TypeError:
             raise RequirementException
         client_id, client_secret = require_split(auth_data, 2, ":")
         client = OAuth2Client.get_token(client_id)
         require(client)
         require(client.secret == client_secret)
         return client
     except RequirementException:
         abort(401, headers=[("WWW-Authenticate", 'Basic realm="reddit"')])
开发者ID:ArslanRafique,项目名称:reddit,代码行数:16,代码来源:oauth2.py


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