OpenID not returning data from correct scope

glasspass
Contributor
Contributor

Hey guys,

 

I'm trying to get Paypal Attributes and Address from the OpenID API in the Sandbox environment. My PayPal button is as follows:

 

paypal.use( ['login'], function (login) {
						  login.render ({
							"appid": clientid,
							"authend": authend,
							"scopes":"openid https://uri.paypal.com/services/paypalattributes address",
							"containerid":"lippButton",
							"locale":"en-us",
							"returnurl":root+ "PayPalServlet"
						  });

Permissions are properly granted in the popup and my servlet correctly generates a Bearer token and makes the request to "/v1/oauth2/token/userinfo?schema=openid". It looks like everything should be working, but my response body is always limited to the following attributes:

 

{"user_id":"https://www.paypal.com/webapps/auth/identity/user/OWFLZYxhts-fpd5jv0kiGkM0YmJPNND9Mox_dc5KjuQ","address":{"street1":"1 Main St","street2":""}}]]

I don't get any error messages. 

 

I'm wondering why my response body has brackets at the end and why the rest of the address attributes and the PayPal Attributes are not being returned.

 

I'm using Apache's HTTPGet to make the request and CloseableHttpResponse to get the results on my Java Glassfish backend. I extract the response body with the following method:

 

private static JsonObject GetResponseBody(CloseableHttpResponse httpResponse){
        if (httpResponse != null) {
            HttpEntity resEntity = httpResponse.getEntity();
            JsonObject responseObj = null;
            if (resEntity != null) {
                try {
                    InputStream is = resEntity.getContent();
                    String responseStr = IOUtils.toString(is, "UTF-8");
                    System.out.println(responseStr);
                    is.close();
                    if (responseStr != null && !responseStr.isEmpty()) {
                        JsonParser parser = new JsonParser();
                        responseObj = parser.parse(responseStr).getAsJsonObject();
                    }
                } catch (IOException e) {
                    Logger.getLogger(PayPalHandler.class.getName()).log(Level.SEVERE, null, e);
                }
            }
            return responseObj;
        }
        return null;
    }

 

Thanks in advance.

Login to Me Too
3 REPLIES 3

glasspass
Contributor
Contributor

Edit: Changed my getResponseBody method to: 

 

private static JsonObject GetResponseBody(CloseableHttpResponse httpResponse){
        if (httpResponse != null) {
            HttpEntity resEntity = httpResponse.getEntity();
            JsonObject responseObj = null;
            if (resEntity != null) {
                try {
                    //InputStream is = resEntity.getContent();
                    String responseStr = EntityUtils.toString(resEntity);
                    System.out.println(responseStr);
                    //is.close();
                    if (responseStr != null && !responseStr.isEmpty()) {
                        JsonParser parser = new JsonParser();
                        responseObj = parser.parse(responseStr).getAsJsonObject();
                    }
                } catch (IOException e) {
                    Logger.getLogger(PayPalHandler.class.getName()).log(Level.SEVERE, null, e);
                }
            }
            return responseObj;
        }
        return null;
    }

Now I'm getting 

{"user_id":"https://www.paypal.com/webapps/auth/identity/user/OWFLZYxhts-fpd5jv0kiGkM0YmJPNND9Mox_dc5KjuQ","address":{"postal_code":"95131","country":"US","state":"CA","street1":"1 Main St","street2":"","city":"San Jose"},"verified_account":"true"}]]

However, I'm still not getting age_range or account_type. Any tips?

Login to Me Too

Mischer86
Contributor
Contributor

Does any news about this issue? I have the same problem with receiving account_type.

Login to Me Too

glasspass
Contributor
Contributor

Unfortunately not.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.