How to get Access Token paypal in android
<p>I am using <code>paypal</code> <a href="https://github.com/paypal/PayPal-Android-SDK" rel="nofollow">SDK</a> in my project,I am able to make payment from my app,but i am not able to get <code>access token</code> after payment,</p>

<p>This my onActivityResult</p>

<pre><code> @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE_PAYMENT) {
            if (resultCode == Activity.RESULT_OK) {
                PaymentConfirmation confirm =
                        data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
                if (confirm != null) {
                    try {
                        Log.i(TAG, confirm.toJSONObject().toString(4));
                        Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));


                        /**
                         *  TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
                         * or consent completion.
                         * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                         * for more details.
                         *
                         * For sample mobile backend interactions, see
                         * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
                         */
                        displayResultText("PaymentConfirmation info received from PayPal");

                        new DownloadLink().execute();


                    } catch (JSONException e) {
                        Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                    }
                }
</code></pre>

<p>This is how i trying to get Access Token</p>

<pre><code> class DownloadLink extends AsyncTask&lt;Void, Void, Void&gt; {


        @Override
        protected Void doInBackground(Void... params) {
            // TODO Auto-generated method stub


         HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("https://api.sandbox.paypal.com/v1/oauth2/token");

            try {
                String text="AUDZWiH7HHihjLqUT3....."+":"+"EDx-t8O2h1.......";
                byte[] data = text.getBytes("UTF-8");
                String base64 = Base64.encodeToString(data, Base64.NO_WRAP);

                httppost.addHeader("content-type", "application/x-www-form-urlencoded");
                httppost.addHeader("Authorization", "Basic " + base64);

                StringEntity se=new StringEntity("grant_type=client_credentials");
                httppost.setEntity(se);

// Execute HTTP Post Request
                HttpResponse response = httpclient.execute(httppost);
                String responseContent = EntityUtils.toString(response.getEntity());
                Log.d("Response", responseContent );

            } catch (ClientProtocolException e) {
// TODO Auto-generated catch block
            } catch (IOException e) {
// TODO Auto-generated catch block
            }
            //Do Your stuff here..
            return null;
        }
    }
</code></pre>

<p>I also used with volly as well as CURL</p>

<pre><code> public void getaccesstokens()
    {
        String clientID="AUDZWiH7H.........";
        String clientSecret="EDx-t8O2h1.....";
        String text=clientID+":"+clientSecret;
        byte[] data = new byte[0];
        try {
            data = text.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        final String base64 = Base64.encodeToString(data, Base64.NO_WRAP);
        StringRequest postRequest=new StringRequest(Request.Method.POST,"https://api.sandbox.paypal.com/v1/oauth2/token",new Response.Listener&lt;String&gt;() {
            @Override
            public void onResponse(String response) {

                Log.d("accessToken:", response);
            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        Log.d("error:",volleyError.toString());

                    }
                }){


            @Override
            protected Map&lt;String, String&gt; getParams() throws AuthFailureError {

                Map&lt;String,String&gt; params=new HashMap&lt;String,String&gt;();
                params.put("grant_type","client_credentials");
                params.put("Authorization", "Basic "+base64);

                return params;

            }

            @Override
            public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                Map&lt;String,String&gt; headers=new HashMap&lt;String,String&gt;();
                headers.put("Accept","application/json");
                headers.put("Accept-Language","en_US");
                headers.put("Content-Type","application/x-www-form-urlencoded");
                return headers;
            }

        };
        postRequest.setRetryPolicy(new

                DefaultRetryPolicy(60000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        Volley.newRequestQueue(Testones.this).add(postRequest);

    }
</code></pre>

<p>Using Volly it shows this error in my logcat</p>

<pre><code>D/error:﹕ com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Connection closed by peer
</code></pre>