angel
angel

Reputation: 4640

An active access token must be used to query information about the current user with facebook-android-sdk:4.+

I am working with

compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:audience-network-sdk:4.+'

I could say I (almost) copied and paste the code of

https://developers.facebook.com/docs/graph-api/reference/v2.5/group

android sdk tab.

then my code is it:

    public GraphResponse Get(String query)
    {
        final GraphResponse[] respuesta = new GraphResponse[1];
        /* make the API call */
        new GraphRequest(
                AccessToken.getCurrentAccessToken(),
                query,
                null,
                HttpMethod.GET,
                new GraphRequest.Callback() {
                    public void onCompleted(GraphResponse response) {
            /* handle the result */

                        respuesta[0] =response;
                    }
                }
        ).executeAndWait();
return  respuesta[0];
    }

and query value is me?fields=id,name,picture

I alwas get

{"error":{"type":"OAuthException","message":"An active access token must be used to query information about the current user.","fbtrace_id":"BADDWWomMZw","code":2500}}

even if I delete data of my application in "application manager" in settings and I loggin again, then I re-try and I got the same message.

I have changed now the value of query for me and this works fine (but it does not return the data which I want)

Upvotes: 0

Views: 3720

Answers (1)

angel
angel

Reputation: 4640

Solved

me?fields=id,name,picture

not work because ?fields=id,name,picture is not part of link, else they hay parameters then, they are added with a bundle

        Bundle parameters = new Bundle();
        parameters.putString("fields", "id,name,picture");

 new GraphRequest(
                AccessToken.getCurrentAccessToken(),
                query,
                parameters,
                HttpMethod.GET,
                new GraphRequest.Callback() {
                    public void onCompleted(GraphResponse response) {
            /* handle the result */

                        respuesta[0] =response;
                    }
                }
        ).executeAndWait();

then this works

Upvotes: 2

Related Questions