Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:58:47+00:00 2026-06-02T11:58:47+00:00

I am using android-facebook-sdk and i am trying to request profile information. But i

  • 0

I am using android-facebook-sdk and i am trying to request profile information. But i cant get the response back. I have generated key hash with keytool and pasted it in the facebook app settings. Also i have added app ID in the code. Problem is that i cant get the profile information, or any information at all.

 public class StartingPoint extends Activity {

    Facebook facebook = new Facebook("actual app id");
    String FILENAME = "AndroidSSO_data";
    private SharedPreferences mPrefs;
    AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);


    Button btnt;

    /*
     * On Create
     * */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        /*
         * button Test
         * */
        btnt = (Button) findViewById(R.id.btntallinn);
        btnt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getProfileInformation();
            }
        });

        /*
         * Get existing access_token if any
         */
        mPrefs = getPreferences(MODE_PRIVATE);
        String access_token = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);
        if (access_token != null) {
            facebook.setAccessToken(access_token);
        }
        if (expires != 0) {
            facebook.setAccessExpires(expires);
        }

        /*
         * Only call authorize if the access_token has expired.
         */
        if (!facebook.isSessionValid()) {

            facebook.authorize(this, new String[] { "email",
                    "publish_checkins", "rsvp_event", "manage_pages",
                    "publish_stream", "user_likes", "user_groups" },

            new DialogListener() {
                @Override
                public void onComplete(Bundle values) {
                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("access_token", facebook.getAccessToken());
                    editor.putLong("access_expires",
                            facebook.getAccessExpires());
                    editor.commit();


                }

                @Override
                public void onFacebookError(FacebookError error) {
                }

                @Override
                public void onError(DialogError e) {
                }

                @Override
                public void onCancel() {
                }

            });

        }
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        facebook.extendAccessTokenIfNeeded(this, null);
    }


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

        facebook.authorizeCallback(requestCode, resultCode, data);
        }


    public void getProfileInformation() {

        mAsyncRunner.request("me", new RequestListener() {

            @Override
            public void onComplete(String response, Object state) {
                Log.d("Profile", response);
                String json = response;

                try {
                    JSONObject profile = new JSONObject(json);
                    // getting name of the user
                    final String name = profile.getString("name");
                    // getting email of the user
                    final String email = profile.getString("email");

                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(), "Name: " + name + "\nEmail: " + email, Toast.LENGTH_LONG).show();
                        }

                    });

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onIOException(IOException e, Object state) {
            }

            @Override
            public void onFileNotFoundException(FileNotFoundException e,
                    Object state) {
            }

            @Override
            public void onMalformedURLException(MalformedURLException e,
                    Object state) {
            }

            @Override
            public void onFacebookError(FacebookError e, Object state) {
            }
        });
    }
}

Logcat:

03-22 09:38:13.545: D/Profile(23833): {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
03-22 09:38:13.545: W/System.err(23833): org.json.JSONException: No value for name
03-22 09:38:13.545: W/System.err(23833):    at org.json.JSONObject.get(JSONObject.java:354)
03-22 09:38:13.545: W/System.err(23833):    at org.json.JSONObject.getString(JSONObject.java:510)
03-22 09:38:13.545: W/System.err(23833):    at com.tana.tallinn.tartu.StartingPoint$3.onComplete(StartingPoint.java:172)
03-22 09:38:13.545: W/System.err(23833):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:254)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:58:48+00:00Added an answer on June 2, 2026 at 11:58 am

    Error says you don’t have required access token. try to print facebook.getaccesstoken() and see if you have valid token.with this token you can try in browser to see if you get profile information

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using facebook-android-sdk for a single sign on, but i can`t get user
I want to check in using facebook android sdk (graph api), I am trying
I'm trying to build an application using the facebook-android-sdk. I've pulled the sdk off
I have an issue with SSO using the Facebook SDK for Android. The problem
I'm trying the Facebook Android SDK, but I don't know where to insert my
I am using android-facebook sdk to share to facebook. Sharing works fine. But, i
I have a lot of apps published using the FB android sdk github.com/facebook/facebook-android-sdk All
I am using the official Facebook SDK for Android in my app. I have
I'm using facebook-android-sdk to post messages to my wall. The following request: Bundle params
I have a FB chat client developed for Android. I've been using facebook android-sdk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.