本文整理汇总了Python中open_facebook.api.FacebookAuthorization.get_cached_app_access_token方法的典型用法代码示例。如果您正苦于以下问题:Python FacebookAuthorization.get_cached_app_access_token方法的具体用法?Python FacebookAuthorization.get_cached_app_access_token怎么用?Python FacebookAuthorization.get_cached_app_access_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类open_facebook.api.FacebookAuthorization
的用法示例。
在下文中一共展示了FacebookAuthorization.get_cached_app_access_token方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_register
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import get_cached_app_access_token [as 别名]
def test_register(self):
return 'currently this doesnt work reliably with the live facebook api'
#setup the test user
permissions = facebook_settings.FACEBOOK_DEFAULT_SCOPE
app_access_token = FacebookAuthorization.get_cached_app_access_token()
test_user = FacebookAuthorization.get_or_create_test_user(app_access_token, permissions)
#test the connect view in the registration mode (empty db)
c = Client()
url = reverse('facebook_connect')
access_token = test_user.access_token
response = c.get(url, {'facebook_login': '1', 'access_token': access_token})
self.assertEqual(response.status_code, 302)
user = User.objects.all().order_by('-id')[:1][0]
profile = user.get_profile()
self.assertEqual(access_token, profile.access_token)
#test the login flow
response = c.get(url, {'facebook_login': '1', 'access_token': access_token})
self.assertEqual(response.status_code, 302)
new_user = User.objects.all().order_by('-id')[:1][0]
new_profile = user.get_profile()
self.assertEqual(access_token, new_profile.access_token)
self.assertEqual(user, new_user)
示例2: test_extend_token
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import get_cached_app_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: test_create_test_user
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import get_cached_app_access_token [as 别名]
def test_create_test_user(self):
#Also, somehow unittest.skip doesnt work with travis ci?
return 'Skipping since you might have created test users manually, lets not delete them :)'
#start by clearing out our test users (maybe this isnt safe to use in testing)
#if other people create test users manualy this could be annoying
app_access_token = FacebookAuthorization.get_cached_app_access_token()
FacebookAuthorization.delete_test_users(app_access_token)
#the permissions for which we want a test user
permissions = ['email', 'publish_actions']
#gets the test user object
test_user = FacebookAuthorization.get_or_create_test_user(app_access_token, permissions)
graph = test_user.graph()
me = graph.me()
assert me
示例4: get_users_fb_email
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import get_cached_app_access_token [as 别名]
def get_users_fb_email(request):
app_access_token = FacebookAuthorization.get_cached_app_access_token()
graph = get_persistent_graph(request, access_token=app_access_token)
return graph.me()['email']
示例5: get_facebook_friends
# 需要导入模块: from open_facebook.api import FacebookAuthorization [as 别名]
# 或者: from open_facebook.api.FacebookAuthorization import get_cached_app_access_token [as 别名]
def get_facebook_friends(request):
app_access_token = FacebookAuthorization.get_cached_app_access_token()
graph = get_persistent_graph(request, access_token=app_access_token)
converter = FacebookUserConverter(graph)
friends_uids = ','.join([str(f['uid']) for f in converter.get_friends()])
return graph.fql('SELECT name, username, pic_square, pic FROM user WHERE uid IN (%s)' % friends_uids)