/** * Construct a request message, send it to the service provider and get the * response. * * @return the response * @throws URISyntaxException * the given url isn't valid syntactically * @throws OAuthProblemException * the HTTP response status code was not 200 (OK) */ @SuppressWarnings("rawtypes") public OAuthMessage invoke(OAuthAccessor accessor, String url, Collection<? extends Map.Entry> parameters) throws IOException, OAuthException, URISyntaxException { return invoke(accessor, null, url, parameters); }
/** @deprecated */ public OAuthMessage invoke(OAuthMessage request, ParameterStyle style) throws IOException, OAuthException { return invoke(request, style.getReplacement()); }
OAuthMessage message = client.invoke(request, ParameterStyle.AUTHORIZATION_HEADER);
/** * Construct a request message, send it to the service provider and get the * response. * * @param httpMethod * the HTTP request method, or null to use the default method * @return the response * @throws URISyntaxException * the given url isn't valid syntactically * @throws OAuthProblemException * the HTTP response status code was not 200 (OK) */ @SuppressWarnings("rawtypes") public OAuthMessage invoke(OAuthAccessor accessor, String httpMethod, String url, Collection<? extends Map.Entry> parameters) throws IOException, OAuthException, URISyntaxException { OAuthMessage request = accessor.newRequestMessage(httpMethod, url, parameters); Object accepted = accessor.consumer.getProperty(OAuthConsumer.ACCEPT_ENCODING); if (accepted != null) { request.getHeaders().add(new OAuth.Parameter(HttpMessage.ACCEPT_ENCODING, accepted.toString())); } Object ps = accessor.consumer.getProperty(PARAMETER_STYLE); net.oauth.ParameterStyle style = (ps == null) ? net.oauth.ParameterStyle.BODY : Enum.valueOf(net.oauth.ParameterStyle.class, ps.toString()); return invoke(request, style); }
OAuthMessage response = invoke(accessor, httpMethod, accessor.consumer.serviceProvider.requestTokenURL, parameters); accessor.requestToken = response.getParameter(OAuth.OAUTH_TOKEN);
message.getHeaders().add(new SimpleEntry<String, String>("oauth_version", "1.0")); OAuthClient client = new OAuthClient(httpFetcher); responseStream = client.invoke(message, net.oauth.ParameterStyle.BODY).getBodyAsStream();
OAuthMessage message; try { message = oauthClient.invoke(accessor, method, url, queryParameters); messageString = message.readBodyAsString(); } catch (IOException e) {
OAuthMessage response = invoke(accessor, httpMethod, accessor.consumer.serviceProvider.accessTokenURL, parameters); response.requireParameters(OAuth.OAUTH_TOKEN, OAuth.OAUTH_TOKEN_SECRET);
try { OAuthMessage message = oauthClient.invoke(accessor, GET, accessor.consumer.serviceProvider.accessTokenURL, null); accessToken = message.getToken(); tokenSecret = message.getParameter(OAuth.OAUTH_TOKEN_SECRET);
@Test public void testGetWebSudoProtectedResourcePermitsOAuthToByPassWebSudo() throws Exception { // setup the consumer first. setUpOAuthConsumer(); OAuthAccessor accessor = createAccessor(CONSUMER_KEY); OAuthClient client = new OAuthClient(new HttpClient4()); // make the request. OAuthMessage response = client.invoke(accessor, getResourceUri().toString(), ImmutableMap.of("oauth_token", "").entrySet()); // assert stuff assertEquals(HttpServletResponse.SC_OK, ((OAuthResponseMessage) response).getHttpResponse().getStatusCode()); assertEquals("hello", response.readBodyAsString()); }
accessor.setProperty(OAuthConstants.PRIVATE_KEY, client.getSecret()); OAuthMessage message = oaClient.invoke(accessor, getAddress().toString(), MapUtilities.toList(props));