简体   繁体   English

facebook offline_access与access_token

[英]facebook offline_access vs access_token

I have read Q&As in here and other threads to understand how facebook handles offline_access and I am still not completely understanding how it works, so please someone explain to me. 我已经在这里和其他主题中阅读了问答,以了解Facebook如何处理offline_access,但我仍不完全了解它的工作原理,因此请有人向我解释。

Seems like facebook still supports client apps to access user info without having to ask user to log in everytime. 好像facebook仍然支持客户端应用程序来访问用户信息,而不必每次都要求用户登录。 (if authorization is granted by user at least once during installation of client app, for example) (例如,如果在安装客户端应用程序期间至少由用户授予一次授权)

The access_token which enables all this seems a bit confusing to understand correctly. 启用所有这些功能的access_token似乎使正确理解有些混乱。

I see that in c# code, access_token is read-only property so client app can't save and reuse, client app has to ask for the token on behalf of user everytime to the authorization server (facebook server). 我看到在c#代码中,access_token是只读属性,因此客户端应用程序无法保存和重复使用,客户端应用程序每次都必须代表用户向授权服务器(facebook服务器)请求令牌。 Then there are people saying offline_access (access_token with long term use, expiration period about 60 days) is necessary and some people say default access_token (1-2 hours) is good enough, you just ask for it each time. 然后有人说离线访问(需要长期使用的访问令牌,有效期约60天)是必要的,并且有人说默认访问令牌(1-2小时)就足够了,您每次都要求。

Can anybody clarify and please provide some C# code or link containg code? 任何人都可以澄清并请提供一些C#代码或包含链接的代码吗?

Thanks in advance 提前致谢

If you have offline_access selected when the user is giving your application permission, all it means is that the access_token that is returned has a long term life - this means that you don't need to re-issue an access_token to make posts (or whatever) on their behalf. 如果在用户授予您的应用程序许可offline_access选择了offline_access ,则意味着返回的access_token具有很长的使用寿命-这意味着您无需重新发出access_token即可发布信息(或其他方法) ) 代表他们。 Without offline_access , you would need to re-issue the access token each time you wanted to do anything to their account. 如果没有offline_access ,则每次想对他们的帐户进行任何操作时都需要重新颁发访问令牌。

If you were to use the 2 hour access_token , when that expired, the user would need to log into Facebook before a new access_token could be issued - meaning you'd need to redirect them to the Facebook login page and then a the token would be sent back to you. 如果要使用2个小时的access_token ,则在过期后,用户需要先登录Facebook,然后才能发布新的access_token这意味着您需要将其重定向到Facebook登录页面,然后令牌将变为发送给您。 It's a less convenient method, however I've had nothing but struggles trying to use the offline_access option 这是一种不太方便的方法,但是除了尝试使用offline_access选项外,我一无所有

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM