简体   繁体   English

如何获得Facebook AccessToken?

[英]How to get Facebook AccessToken?

I have a Facebook Session.but it is not open. 我有一个Facebook Session。但是它没有打开。 i tried to get AccessToken as follows 我试图获取AccessToken如下

Session.getActiveSession().getAccessToken();

but it does not return any thing.how can i get the AccessToken? 但是它没有返回任何东西。我如何获得AccessToken?

well, as written in the official documentation , you need to have a UiLifecycleHelper that will make sure to create a valid session for every fragment that interacts with the Facebook SDK. 好吧,正如官方文档中所述,您需要有一个UiLifecycleHelper ,以确保为与Facebook SDK交互的每个片段创建一个有效的会话。

what you should do is override the life cycle methods in your fragment (or activity) and then Session.getActiveSession() will return a session if there is one. 您应该做的是重写片段(或活动)中的生命周期方法,然后Session.getActiveSession()将返回一个会话(如果有)。

You almost never need to extract the actual access token anymore. 您几乎不再需要提取实际的访问令牌。 Any requests to the graph API can be done with the Request class and a Session object. 对图形API的任何请求都可以使用Request类和Session对象完成。

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

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