Skip to Content
0

Peer not authenticated exception when connecting SAP Cloud Platform to Office 365 API

Aug 15, 2017 at 11:42 AM

232

avatar image

I'm implementing an SAP Cloud Platform Java application to connect to the Office 365 API (https://outlook.office.com/) using OAuth2 authentication.

When I running it on Apache Tomcat local server I get the response from the server correctly.

When I run the same code on SAP Cloud Platform I get javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated|

In both cases I get the correct OAuth token.

What am I missing here? The code I'm using is:

privateObject getResponseFromAzure(String url,String methodType){AuthenticationResult result =null;try{
        result = getAccessTokenFromUserCredentials();// OAuth2 bearer token}catch(Exception e1){// TODO Auto-generated catch block
        e1.printStackTrace();}String accessToken = result.getAccessToken();System.out.println("Access Token is - "+ accessToken);HttpClient client =newDefaultHttpClient();HttpRequestBase request =null;if("GET".equals(methodType)){
        request =newHttpGet(url);}elseif("POST".equals(methodType)){
        request =newHttpPost(url);}

    request.addHeader("Authorization","Bearer "+ accessToken);HttpResponse response =null;try{
        response = client.execute(request);}catch(ClientProtocolException e){// TODO Auto-generated catch block
        e.printStackTrace();}catch(IOException e){// TODO Auto-generated catch block
        e.printStackTrace();}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers