-4

Please how do I get the refresh_token out of this JSON ??

{"scope":"https://api.paypal.com/v1/vault/credit-card https://uri.paypal.com/services/payments/futurepayments https://uri.paypal.com/services/invoicing openid https://api.paypal.com/v1/vault/credit-card/.* https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/payments/.*","access_token":"fsdmpd19QszG4n-6mokPXS7uShe9qDO84kqQyR5kYVE","token_type":"Bearer","expires_in":900,"refresh_token":"WJAvbjuCzIOdgEsYUfywhxrygKQaCoaJo_F5pj7RMJERiovBmy1ua0Qhs81a_uLuiqjayJrqhycShf0TXHWKq7JbZZ4"}
Lisa Anne
  • 4,482
  • 17
  • 83
  • 157

2 Answers2

2

Try this..

try
{
    JSONObject object = new JSONObject(response);
    String refresh_token = object.getString("refresh_token");

}catch (JSONException e) {
    e.printStackTrace();
}
Hariharan
  • 24,741
  • 6
  • 50
  • 54
1

It can be done like this:

public String getToken(String url) throws JSONException {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(url);
    try {
        HttpResponse response = httpclient.execute(httpGet);
        JSONObject data = new JSONObject(EntityUtils.toString(response.getEntity()));
        return data.getString("refresh_token");
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
nikis
  • 11,166
  • 2
  • 35
  • 45