"Invalid appsecret_proof.." although everything set up correctly

740 views
Skip to first unread message

Daniel Füvesi

unread,
Jun 6, 2015, 10:51:33 AM6/6/15
to res...@googlegroups.com
Hi,

I have an fxml method in my desktop application from where I'd like to make a facebook post. Following your guide, I wrote this code:


@FXML
public void shareFacebookClicked() throws Exception{
String appID = "MY_APP_ID";
String appSecret = "MY_APP_SECRET";
String accessToken = "MY_ACCESS_TOKEN";

FacebookClient facebookClient = new DefaultFacebookClient(accessToken, appSecret, Version.VERSION_2_3);
String proof = new DefaultFacebookClient().obtainAppSecretProof(
accessToken, appSecret);
System.out.println("Here's my proof: " + proof);
FacebookType publishMessageResponse =
facebookClient.publish("me/feed", FacebookType.class,
Parameter.with("message", "RestFB test"));

System.out.println("Published message ID: " + publishMessageResponse.getId());


When I run the program and click the corresponding button I receive the common exception:

"Caused by: com.restfb.exception.FacebookGraphException: Received Facebook error response of type GraphMethodException: Invalid appsecret_proof provided in the API argument (code 100, subcode null)
at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1230)
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1134)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1067)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:978)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:470)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:494)"

What am I doing wrong? FYI: in the maven dependency I'm using version 1.11.0 of restfb.
Thanks for the help in advance!










Norbert Bartels

unread,
Jun 7, 2015, 1:03:38 PM6/7/15
to res...@googlegroups.com, dvg...@hotmail.com

Hi Daniel,

Please add Parameter.with("appsecret_proof",proof) next to your Parameter.with('message', 'RestFB Test').

This should work.

Norbert

Daniel Füvesi

unread,
Jun 7, 2015, 6:14:54 PM6/7/15
to res...@googlegroups.com, dvg...@hotmail.com
Hi Norbert,

Thank you for your help. Unfortunately, your mentioned approach did not solve the problem. If I understood you correctly my method should look like this:

String appID = "MY_APP_ID";
String appSecret = "MY_APP_SECRET";
String accessToken = "MY_ACCESS_TOKEN";

FacebookClient facebookClient = new DefaultFacebookClient(accessToken, appSecret, Version.VERSION_2_3);
String proof = new DefaultFacebookClient().obtainAppSecretProof(
accessToken, appSecret);
System.out.println("Here's my proof: " + proof);
FacebookType publishMessageResponse =
facebookClient.publish("me/feed", FacebookType.class,
                Parameter.with("message", "RestFB test"),
Parameter.with("appsecret_proof", proof));

System.out.println("Published message ID: " + publishMessageResponse.getId());

However, I'm still getting the same exception about the invalid appsecret_proof. For now, I made a simple URL redirection (Facebook URL Redirection) given using a WebView (JavaFX). I'll continue to check out this group in case you or someone else suggests another solution/option.

Daniel




Norbert Bartels

unread,
Jun 8, 2015, 7:07:01 AM6/8/15
to res...@googlegroups.com, dvg...@hotmail.com
Okay, I'll write an integration test to check this issue.

Norbert

Norbert Bartels

unread,
Jun 9, 2015, 4:08:26 PM6/9/15
to res...@googlegroups.com, vie...@gmail.com, dvg...@hotmail.com
So, I added an integration Test that fetches `/me` with the `appsecret_proof` and this is working correctly. 

Perhaps there's an issue with publishing an information, but in general everything's fine. BTW I don't use the additional parameter.

I'll check the publishing and tell you want I find :)

Norbert

Norbert Bartels

unread,
Jun 9, 2015, 6:12:44 PM6/9/15
to res...@googlegroups.com, vie...@gmail.com, dvg...@hotmail.com

An publishing integration test works, too. You can have a look at the current dev branch or here:
https://github.com/restfb/restfb/issues/243

Norbert

Daniel Füvesi

unread,
Jun 9, 2015, 7:31:10 PM6/9/15
to res...@googlegroups.com, dvg...@hotmail.com
Hello Norbert,

Thank you again for the help. I'll check out your code and use it as it is (with different parameters of course). I hope it's going to work.
Have a nice day!

Daniel
Reply all
Reply to author
Forward
0 new messages