I am using restfb java sdk for adding facebook login in my app
i have already created a test app but when i try to get the detail of the user following error message displayed
[FacebookOAuthException: Received Facebook error response of type OAuthException: An active access token must be used to query information about the current user. (code 2500, subcode null)]
here is my code
val config = ConfigFactory.load()
val FBAppId = config.getString("fb.app.id")
val FBAppSecret = config.getString("fb.app.secretkey")
val aceessToken = new DefaultFacebookClient().obtainAppAccessToken(FBAppId, FBAppSecret)
log.info("token is "+aceessToken.getAccessToken)
val facebookClient = new DefaultFacebookClient(aceessToken.getAccessToken)
val fbuser = facebookClient.fetchObject("me",classOf[User] ,Parameter.`with`("fields", "id,name,email, first_name , last_name"))
log.info("name : {} ", fbuser.getName)
log.info("User first name :{} ", fbuser.getFirstName)
log.info("User last name : {}" , fbuser.getLastName)
log.info("User Email : {}" , fbuser.getEmail)
here is the access token printed on console
token is 587299244766256|udH5HgYve1DHGjKHU55hBw9Ik5Y
(i think this in not correct as i have read in Facebook docs that access token consists of 150 characters and the token that is generating is not 150 character long ) and in this line
val fbuser = facebookClient.fetchObject("me",classOf[User] ,Parameter.`with`("fields", "id,name,email, first_name , last_name"))
the exception thrown
[FacebookOAuthException: Received Facebook error response of type OAuthException: An active access token must be used to query information about the current user. (code 2500, subcode null)]
please help me how can i get the details of logged in users
You cannot fetch the endpoint me
with an app access token. You need a user or page access token.