/** * Returns a collection of parameters of the client info request. Any * <code>null</code> or empty parameter will be omitted. * * @return A collection of parameters. */ public Map<String, String> getParameters() { Map<String, String> parameters = new HashMap<String, String>(); if (accessToken != null && !accessToken.isEmpty()) { if (getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER || getAuthorizationMethod() == AuthorizationMethod.URL_QUERY_PARAMETER) { parameters.put("access_token", accessToken); } } return parameters; } }
/** * Returns a query string with the parameters of the Client Info request. * Any <code>null</code> or empty parameter will be omitted. * * @return A query string of parameters. */ @Override public String getQueryString() { StringBuilder queryStringBuilder = new StringBuilder(); if (accessToken != null && !accessToken.isEmpty()) { if (getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER || getAuthorizationMethod() == AuthorizationMethod.URL_QUERY_PARAMETER) { queryStringBuilder.append("access_token=").append(accessToken); } } return queryStringBuilder.toString(); }
@Override public String getHttpMethod() { if (getRequest().getAuthorizationMethod() == null || getRequest().getAuthorizationMethod() == AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD || getRequest().getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) { return HttpMethod.POST; } else { // AuthorizationMethod.URL_QUERY_PARAMETER return HttpMethod.GET; } }
clientRequest.setHttpMethod(getHttpMethod()); if (getRequest().getAuthorizationMethod() == null || getRequest().getAuthorizationMethod() == AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD) { if (StringUtils.isNotBlank(getRequest().getAccessToken())) { clientRequest.header("Authorization", "Bearer " + getRequest().getAccessToken()); } else if (getRequest().getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) { if (StringUtils.isNotBlank(getRequest().getAccessToken())) { clientRequest.formParameter("access_token", getRequest().getAccessToken()); } else if (getRequest().getAuthorizationMethod() == AuthorizationMethod.URL_QUERY_PARAMETER) { if (StringUtils.isNotBlank(getRequest().getAccessToken())) { clientRequest.queryParameter("access_token", getRequest().getAccessToken()); if (getRequest().getAuthorizationMethod() == null || getRequest().getAuthorizationMethod() == AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD || getRequest().getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) { clientResponse = clientRequest.post(String.class); } else { //AuthorizationMethod.URL_QUERY_PARAMETER