本文整理汇总了Python中open_facebook.api.FacebookAuthorization.extend_access_token方法的典型用法代码示例。如果您正苦于以下问题:Python FacebookAuthorization.extend_access_token方法的具体用法?Python FacebookAuthorization.extend_access_token怎么用?Python FacebookAuthorization.extend_access_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类open_facebook.api.FacebookAuthorization
的用法示例。
在下文中一共展示了FacebookAuthorization.extend_access_token方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _extend_access_token
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def _extend_access_token(self, access_token):
from open_facebook.api import FacebookAuthorization
results = FacebookAuthorization.extend_access_token(access_token)
access_token = results['access_token']
self.access_token = access_token
self.save()
return results
示例2: test_extend_token
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def test_extend_token(self):
return 'this doesnt work in travis, but locally its fine... weird'
app_access_token = FacebookAuthorization.get_cached_app_access_token()
test_user = FacebookAuthorization.get_or_create_test_user(app_access_token)
access_token = test_user.access_token
results = FacebookAuthorization.extend_access_token(access_token)
if 'access_token' not in results:
raise ValueError('we didnt get a fresh token')
示例3: extend_access_tokens
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def extend_access_tokens():
for user in UserEx.objects.filter(facebook_id__isnull=False):
results = FacebookAuthorization.extend_access_token(user.access_token)
access_token = results['access_token']
old_token = user.access_token
token_changed = access_token != old_token
if token_changed:
user.access_token = access_token
user.new_token_required = False
user.save()
示例4: handle_existing_user
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def handle_existing_user(self, provider, user, access, info):
"""Here we store the access token for the facebook page that we got from facebook."""
if len(Token.objects.all()) < 5:
fb = OpenFacebook(access.access_token.split("=")[1])
me = fb.get('me/accounts')
for page in me['data']:
if 'Roseniuskyrkan' in page.values():
token = FacebookAuthorization.extend_access_token(page['access_token'])['access_token']
Token.objects.create(token = token)
return super(LoginCallback, self).handle_existing_user(provider, user, access, info)
示例5: _extend_access_token
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def _extend_access_token(self, access_token):
from open_facebook.api import FacebookAuthorization
results = FacebookAuthorization.extend_access_token(access_token)
access_token, expires = results['access_token'], int(results['expires'])
new_token = access_token != self.access_token
message = 'a new' if new_token else 'the same'
log_format = 'Facebook provided %s token, which expires at %s'
expires_delta = datetime.timedelta(seconds=expires)
logger.info(log_format, message, expires_delta)
if new_token:
logger.info('Saving the new access token')
self.access_token = access_token
self.save()
return results
示例6: _extend_access_token
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def _extend_access_token(self, access_token):
from open_facebook.api import FacebookAuthorization
results = FacebookAuthorization.extend_access_token(access_token)
access_token, expires = results["access_token"], int(results["expires"])
old_token = self.access_token
token_changed = access_token != old_token
message = "a new" if token_changed else "the same"
log_format = "Facebook provided %s token, which expires at %s"
expires_delta = datetime.timedelta(seconds=expires)
logger.info(log_format, message, expires_delta)
if token_changed:
logger.info("Saving the new access token")
self.access_token = access_token
self.save()
from django_facebook.signals import facebook_token_extend_finished
facebook_token_extend_finished.send(sender=self, profile=self, token_changed=token_changed, old_token=old_token)
return results
示例7: _extend_access_token
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import extend_access_token [as 别名]
def _extend_access_token(self, access_token):
from open_facebook.api import FacebookAuthorization
results = FacebookAuthorization.extend_access_token(access_token)
access_token = results['access_token']
old_token = self.access_token
token_changed = access_token != old_token
message = 'a new' if token_changed else 'the same'
log_format = 'Facebook provided %s token, which expires at %s'
expires_delta = timedelta(days=60)
logger.info(log_format, message, expires_delta)
if token_changed:
logger.info('Saving the new access token')
self.access_token = access_token
self.save()
from django_facebook.signals import facebook_token_extend_finished
facebook_token_extend_finished.send(sender=self, profile=self,
token_changed=token_changed, old_token=old_token
)
return results