How to get Access Token paypal in android

前端 未结 1 1816
孤独总比滥情好
孤独总比滥情好 2020-12-12 03:13

I am using paypal SDK in my project,I am able to make payment from my app,but i am not able to get access token after payment,

This my onAc

相关标签:
1条回答
  • 2020-12-12 04:14

    This one worked for me, The issue was with Network connection security,so i changed my wifi, and it works perfectly fine

    That was the reason i was getting this error

    NoConnectionError: javax.net.ssl.SSLHandshakeException: Connection closed by peer
    

    CODE

    HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("https://api.sandbox.paypal.com/v1/oauth2/token");
    
            try {
                String text="CLIENT ID"+":"+"SECRET ID";
                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
            }
    
    0 讨论(0)
提交回复
热议问题