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
To get the accessToken for facebook-sdk 4.* or above. Add this lines after facebookSDKInitialize()
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKEN);
After that use these lines of codes,
AccessToken token = AccessToken.getCurrentAccessToken();
Log.d("Access Token is",token);
Sample:
GraphRequestAsyncTask graphRequestAsyncTask = new GraphRequest(
login_result.getAccessToken(),
//AccessToken.getCurrentAccessToken(),
"/me/friends",
bundle,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
JSONArray rawName = response.getJSONObject().getJSONArray("data");
Log.d("rawName friendList",String.valueOf(rawName));
AccessToken token = AccessToken.getCurrentAccessToken();
Log.d("access token is: ",String.valueOf(token));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
).executeAsync();