简体   繁体   English

如何为永不过期的facebook(restfb)生成访问令牌? (Java)的

[英]How do I generate access token for facebook (restfb) which is never expired? (java)

I'm trying to generate access token for specific user on facebook for restfb so i could share photos with my java app. 我正在尝试为restfb在Facebook上的特定用户生成访问令牌,以便可以与Java应用程序共享照片。 I succeded to generate the token by entring facebook and copying it into my code. 我通过输入facebook并将其复制到我的代码中来成功生成令牌。 My question is is there any way to generate to token from the code itself? 我的问题是,有什么方法可以从代码本身生成令牌吗? And if so how can i support the upload even when the user is not connected to facebook? 如果是的话,即使用户未连接到Facebook,我如何支持上传? Because i'm getting the error: 因为我收到错误:

Exception in thread "main" com.restfb.exception.FacebookOAuthException: 
Received Facebook error response of type OAuthException:
Error validating access token: The session is invalid because the user logged out. 
(code 190, subcode 467)

Thanks a lot. 非常感谢。

Facebook allows you to generate long lived token that lasts 60 days maximum. Facebook允许您生成最长持续60天的长期令牌。 You have no option to create non-expiring token. 您没有选择来创建未过期的令牌。 You might want to extend it, but it cannot be generated as non-expiring token, as described here: https://developers.facebook.com/docs/facebook-login/access-tokens#extending 您可能想要扩展它,但不能将其作为未过期的令牌生成,如此处所述: https : //developers.facebook.com/docs/facebook-login/access-tokens#extending

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

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