本文整理汇总了Python中api.API.verify_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python API.verify_credentials方法的具体用法?Python API.verify_credentials怎么用?Python API.verify_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.API
的用法示例。
在下文中一共展示了API.verify_credentials方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_username
# 需要导入模块: from api import API [as 别名]
# 或者: from api.API import verify_credentials [as 别名]
def get_username(self):
if self.username is None:
api = API(self)
user = api.verify_credentials()
if user:
self.username = user.screen_name
else:
raise WeibopError("Unable to get username, invalid oauth token!")
return self.username
示例2: SinaAPI
# 需要导入模块: from api import API [as 别名]
# 或者: from api.API import verify_credentials [as 别名]
#.........这里部分代码省略.........
def request_access_token(
self,
client_id,
client_secret,
code,
redirect_uri=None,
):
return _request_access_token(
self.client_id,
self.client_secret,
code,
self.redirect_uri,
)
def request_refresh_token(
self,
client_id,
client_secret,
refresh_token,
redirect_uri=None,
):
return _request_refresh_token(
self.client_id,
self.client_secret,
refresh_token,
self.redirect_uri,
)
@check_remain_requests('Too many requests in getCurrentUser')
def getCurrentUser(self):
"""返回当前登录用户的信息,如果未登录,返回False"""
logger.info('api-nail')
try:
status = self.api.verify_credentials()
except WeibopError:
logger.info("WeibopError")
return False
return status
@check_remain_requests('Too many requests in getTags')
def getTags(self, uid, count=20, page=None):
logger.info('api-nail')
if count > 200:
raise Exception('Too many tag counts per page.')
if page:
return self.api.tags(uid=uid, count=count, page=page)
else:
return self.api.tags(uid=uid, count=count)
def getDirectMsgs(self, since_id=None, count=200):
logger.info('api-nail')
page = 1
rvl=[]
while True:
self._testResetTime()
if self.request_limit < 1:
raise TooManyRequests('Too many requests in getDirectMsgs')
self.request_limit -= 1
if since_id:
directMsgs = self.api.direct_messages(since_id=since_id, count=count, page=page)
else:
directMsgs = self.api.direct_messages(count=count, page=page)
rvl.extend(directMsgs)
if len(directMsgs) < count: