Android: Facebook get “User Access Token”, on successful login

前端 未结 6 1057
北恋
北恋 2020-12-24 08:23

I have been doing some login project via Facebook latest SDK i.e. 3.0. I\'m getting a hard time in getting user access token. I have searched on the internet and all, maximu

6条回答
  •  情书的邮戳
    2020-12-24 09:00

    In the method onResume() add the following code (in this case i used Toast.makeText to see the token access after login):

        Session session = Session.getActiveSession();
        if (session.isOpened()) {
            Toast.makeText(getActivity(), session.getAccessToken(), Toast.LENGTH_LONG).show();
        }
    

    I used getActivity because it is in a Fragment in my case, if you have your login button in an Activity use "this" instead of "getActivity()"

提交回复
热议问题