简体   繁体   English

如何在没有应用程序的情况下扩展Facebook访问令牌?

[英]How to extend Facebook access token without an app?

So i imported the Facebook module into python to use it for some personal scripts that i want to create and eventually link this to Arduino. 因此,我将Facebook模块导入python中,以将其用于一些我想创建的个人脚本,并最终将其链接到Arduino。 So let's say i have something like this: 所以说我有这样的事情:

import facebook
import codecs

token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'

graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")

friend_list = [friend['name'].encode('utf-8') for friend in friends['data']]

for i in friend_list:
  print i.decode('utf-8')

This works, however the token that i am generating here expires after one hour. 这可行,但是我在这里生成的令牌在一小时后过期。 I see that the GraphAPI class has some methods for extending access tokens but they need 'app_id' and 'app_secret' as parameters. 我看到GraphAPI类具有一些扩展访问令牌的方法,但是它们需要'app_id'和'app_secret'作为参数。 What is this all about? 这是怎么回事? So my question is, how can i extend this token without a Facebook app? 所以我的问题是,如果没有Facebook应用程序,如何扩展此令牌? Or how can i do something like posted above without a token, based only on user name and password for example? 或者我该如何仅基于用户名和密码来执行上面没有令牌的内容?

Thanks! 谢谢!

I know this question is old, but I am posting in case it is helpful to anyone else since I was just struggling with something similar. 我知道这个问题很旧,但是我发帖是为了对其他人有帮助,因为我只是在努力解决类似问题。

You need a app_id & app_secret to extend the expiration. 您需要一个app_id和app_secret来延长有效期。

If you do have a fb app and want to extend the user token in python, you can extended it to 60 day expiry using the GraphAPI.extend_access_token() method. 如果您确实有一个fb应用程序,并且想要在python中扩展用户令牌,则可以使用GraphAPI.extend_access_token()方法将其扩展到60天到期。

See: How to extend my facebook graph API token in python? 请参阅: 如何在python中扩展我的facebook graph API令牌?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用facebook python sdk在facebook中扩展页面的access_token - How to extend the access_token of a page in facebook using facebook python sdk Facebook应用程序:访问令牌随XMLHttpRequest到期吗? - Facebook app: Access token expires with XMLHttpRequest? 如何在python中扩展我的facebook graph API令牌? - How to extend my facebook graph API token in python? 如何延长 MSAL Python 库的访问令牌过期时间? - How to extend access token expiration time for MSAL Python library? 在没有访问令牌的情况下从python获取Facebook用户名 - Fetching facebook user's name from python without access token 没有使用rauth进行Facebook登录的没有访问令牌的错误URL - Incorrect URL without an access token for facebook login using rauth 获取简单应用程序的Facebook页面访问令牌(Python) - Getting a Facebook page access token for a simple app (Python) 如何在python中从Facebook的oauth重定向获取访问令牌? - How to get the access token from facebook's oauth redirect in python? Facebook:如何使用python获取/更新用户访问令牌? - Facebook: How to get/update user access token using python? 如何解决Facebook在Python中获取访问令牌错误? - how to solve facebook get access token error in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM