简体   繁体   English

如何保存和刷新用户(管理员)的Facebook访问令牌

[英]How to save and refresh Facebook access token of user (admin)

I am thinking to implement Facebook Wordpress Plugin for bloggers in django (using Fandjango & Facepy ). 我正在考虑为django的博客作者实现Facebook Wordpress插件 (使用FandjangoFacepy )。

To be specific: 再具体一点:

The project admin/ developer will be the only person as user. 项目管理员/开发人员将是唯一的用户。 So, the application need to perform /friend_id/feed calls on the admin automatically in the background. 因此,应用程序需要在后台自动在管理员上执行/friend_id/feed调用。

For that all I would need is to store admin's access token and use it when ever I want.. 为此,我需要存储管理员的访问令牌并在需要时使用它。

Now, I got some problems to address: 现在,我有一些问题要解决:

  1. How to refresh the admin's access token when it expires automatically without admin's intervention 当管理员的访问令牌自动过期时,如何在无需管理员干预的情况下刷新

Actually, can we store access token (I mean securely). 实际上,我们可以存储访问令牌吗(我的意思是安全)。 I somewhere read that its not possible (not sure of the information) 我在某处读到它是不可能的(不确定信息)

If the user authorizes this as an app, with the permissions publish_stream (to publish stories to the News Feeds of the user and their Friends) and user_likes (to have access to the pages at the user has 'liked'), you can use: 如果用户将其授权为应用程序,则其权限为publish_stream (将故事发布到用户及其好友的新闻源)和user_likes (可访问用户喜欢的页面),您可以使用:

https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials

to create an App access token. 创建一个应用访问令牌。 Since these do not often change, you can store it if you like, but it may be wise to make the above request each time, so that in case it does change, you are somewhat protected. 由于这些不经常改变,你可以储存它,如果你喜欢,但它可能是明智的,每次上作出上述请求,这样的情况下, 的变化,你是有点保护。

Then, use the Graph API, JS SDK or PHP SDK to publish the story, which is quite straightforward. 然后,使用Graph API,JS SDK或PHP SDK来发布故事,这非常简单。

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

相关问题 如何在 user.save() 之后验证并返回访问和刷新令牌 - How to validate and return access and refresh tokens after user.save() 如何在admin.py中访问当前用户 - How to access current user in admin.py 如何访问(询问)用户登录令牌 - How to access(ask) token for user login 如何在 drf 中通过访问 jwt 令牌向用户发送它 - how to send user it with access jwt token in drf 如何保存在 django 管理站点中创建和修改记录的用户? - How to save user that created and modified a record in django admin site? 如何读取Facebook access_token返回的JSON数据 - How to read JSON data return by the Facebook access_token Facebook集成静态访问令牌 - Facebook Integration Static access token 如何在 Django 的单个 API 中获取访问令牌和刷新令牌(rest_framework_jwt) - How to get access token and refresh token ( rest_framework_jwt ) in a single API in Django 如何使用刷新令牌在 django-oauth-toolkit 上获取新的访问令牌? - How to use refresh token to obtain new access token on django-oauth-toolkit? 如何在 django 管理站点中的管理模型保存功能时向用户发送通知 - how send notification to user when admin model save function in django admin site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM