cancel
Showing results for 
Search instead for 
Did you mean: 

OpenID not returning data from correct scope

Contributor

OpenID not returning data from correct scope

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.

3 REPLIES 3
Highlighted
Contributor

Re: OpenID not returning data from correct scope

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?

Contributor

Re: OpenID not returning data from correct scope

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

Contributor

Re: OpenID not returning data from correct scope

Unfortunately not.