GraphRequest﹕ Warning: Request without access token missing application ID or client token

5.1k views Asked by At

Im using latest Facebook SDK(v4.2.0) for android.

When I tried to post open graph story, logcat says: GraphRequest﹕ Warning: Request without access token missing application ID or client token and story is not being post.

My onCreate method code is:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {//@Overridden method});
}

And Later I called following code from button's onClickListener

LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_action"));

I have also handled callback as:

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);

}

The code I used for open graph post is:

 Bundle params = new Bundle();
    params.putString("match", "http://samples.ogp.me/413385652011237");

    GraphRequest request = new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/tigertraptest:complete",
            params,
            HttpMethod.POST
    );
    GraphResponse response = request.executeAndWait();

Also I have tried all solution suggested in this link: failed solution.

I'm new to Facebook Integration. Please help.

Edit I have posted all codes that I used in my activity to enable Facebook open graph post.

2

There are 2 answers

1
Shoeb Siddique On

You need to pass access token also.

params.putString("access_token", "YOUR_ACCESS_TOKEN");
0
Raghav Chawla On

You have to use accesstokentracker to track your accesstoken since it changes after some time. You also have to add the method onCurrentAccessTokenChanged. You can refer to Getting null response in android fb graph api for the code. Although in that code, group feeds are being fetched but you cam see the part related to access token.