Take the 2-minute tour ×

Since the offline access is stopped by facebook now, how do I store/get a new access token. I have tried a lot. The code is below. I have to give the access token in https://graph.facebook.com/me/friends?access_token=

String url = "https://graph.facebook.com/oauth/access_token?client_id=appid&client_secret=secretid&grant_type=fb_exchange_token&fb_exchange_token=access_token";

            HttpClient httpclient = new DefaultHttpClient();
            HttpGet httpget = new HttpGet(url);

                HttpResponse response = httpclient.execute(httpget);

                HttpEntity entity = response.getEntity();
                is = entity.getContent();

                BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
                StringBuilder sb = new StringBuilder();
                String line = null;


                     sb.append(line + "\n");


                result = result.split("=")[1];

            catch(Exception e)
                AppLog.logger("Error in JSON");

How to exchange token?? Please help.

share|improve this question
what you get in result???? please print that here. –  Dhawal Sodha Parmar May 30 '12 at 13:39
I just got oath exception errors.nothing else.I think the access token needs to be saved somewhere else it expires. Thanx for helping –  Siddharth Bhatia May 31 '12 at 5:59
hey i was asking you what you get in "result" variable?? please print that using "Log.d("Result-->",""+result);" and copy past that here. you can see this in Logcat. –  Dhawal Sodha Parmar May 31 '12 at 8:03
add comment

1 Answer

Why don't you use the Facebook SDK for Android?

share|improve this answer
add comment

Your Answer


