Java Code Examples for org.scribe.model.Verb#GET

The following examples show how to use org.scribe.model.Verb#GET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceClient.java    From jerseyoauth2 with MIT License 7 votes vote down vote up
public SampleEntity retrieveEntitySample1(Token accessToken) throws ClientException
{
	OAuthService service = getOAuthService(scopes, null);
	
	OAuthRequest request = new OAuthRequest(Verb.GET,
			"http://localhost:9998/testsuite/rest/sample/1");
	service.signRequest(accessToken, request);
	Response response = request.send();
	if (response.getCode()!=200)
		throwClientException(response);
	
	ObjectMapper mapper = new ObjectMapper();
	try {
		SampleEntity entity = mapper.readValue(response.getBody(), SampleEntity.class);
		return entity;
	} catch (IOException e) {
		throw new ClientException(response.getBody());
	}
}
 
Example 2
Source File: SmugMugInterface.java    From data-transfer-project with Apache License 2.0 6 votes vote down vote up
private <T> SmugMugResponse<T> makeRequest(
    String url, TypeReference<SmugMugResponse<T>> typeReference) throws IOException {
  // Note: there are no request params that need to go here, because smugmug fully specifies
  // which resource to get in the URL of a request, without using query params.
  String fullUrl;
  if (!url.contains("https://")) {
    fullUrl = BASE_URL + url;
  } else {
    fullUrl = url;
  }
  OAuthRequest request = new OAuthRequest(Verb.GET, fullUrl + "?_accept=application%2Fjson");
  oAuthService.signRequest(accessToken, request);
  final Response response = request.send();

  if (response.getCode() < 200 || response.getCode() >= 300) {
    throw new IOException(
        String.format("Error occurred in request for %s : %s", url, response.getMessage()));
  }

  return mapper.readValue(response.getBody(), typeReference);
}
 
Example 3
Source File: HubicSwift.java    From swift-explorer with Apache License 2.0 6 votes vote down vote up
private static SwiftAccess getSwiftAccess (HubicOAuth20ServiceImpl service, Token accessToken)
{
	String urlCredential = HubicApi.CREDENTIALS_URL;
	
    OAuthRequest request = new OAuthRequest(Verb.GET, urlCredential);
    request.setConnectionKeepAlive(false);
    service.signRequest(accessToken, request);
    Response responseReq = request.send();
    
    SwiftAccess ret = gson.fromJson(responseReq.getBody(), SwiftAccess.class) ;
    ret.setAccessToken(accessToken);
    
    logger.info("Swift access token expiry date: " + ret.getExpires());
    
	return ret ;
}
 
Example 4
Source File: XeroClient.java    From xero-java-client with Apache License 2.0 6 votes vote down vote up
protected com.connectifier.xeroclient.models.Response get(String endPoint, Date modifiedAfter, Map<String,String> params) {
  OAuthRequest request = new OAuthRequest(Verb.GET, BASE_URL + endPoint);
  if (modifiedAfter != null) {
    request.addHeader("If-Modified-Since", utcFormatter.format(modifiedAfter));
  }
  if (params != null) {
    for (Map.Entry<String,String> param : params.entrySet()) {
      request.addQuerystringParameter(param.getKey(), param.getValue());
    }
  }
  service.signRequest(token, request);
  Response response = request.send();
  if (response.getCode() != 200) {
    throw newApiException(response);
  }
  return unmarshallResponse(response.getBody(), com.connectifier.xeroclient.models.Response.class);
}
 
Example 5
Source File: LoginWindow.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request,
        VaadinResponse response) throws IOException {
    if (request.getParameter("code") != null) {
        String code = request.getParameter("code");
        Verifier v = new Verifier(code);
        Token t = service.getAccessToken(null, v);

        OAuthRequest r = new OAuthRequest(Verb.GET,
                "https://www.googleapis.com/plus/v1/people/me");
        service.signRequest(t, r);
        Response resp = r.send();

        GooglePlusAnswer answer = new Gson().fromJson(resp.getBody(),
                GooglePlusAnswer.class);

        userSession.login(answer.emails[0].value, answer.displayName);

        close();
        VaadinSession.getCurrent().removeRequestHandler(this);

        ((VaadinServletResponse) response).getHttpServletResponse().
                sendRedirect(redirectUrl);
        return true;
    }

    return false;
}
 
Example 6
Source File: FacebookAPI.java    From mamute with Apache License 2.0 5 votes vote down vote up
private Response makeRequest(String url) {
	OAuthRequest request = new OAuthRequest(Verb.GET, url);
	service.signRequest(accessToken, request);
	Response response = request.send();
	String body = response.getBody();
	if (response.getCode() / 100 != 2) {
		throw new IllegalArgumentException("http error: " + response.getCode() + ", facebook response body: " + body);
	}
	return response;
}
 
Example 7
Source File: RequestBuilder.java    From jumblr with Apache License 2.0 5 votes vote down vote up
public OAuthRequest constructGet(String path, Map<String, ?> queryParams) {
    String url = "https://" + hostname + "/v2" + path;
    OAuthRequest request = new OAuthRequest(Verb.GET, url);
    if (queryParams != null) {
        for (Map.Entry<String, ?> entry : queryParams.entrySet()) {
            request.addQuerystringParameter(entry.getKey(), entry.getValue().toString());
        }
    }
    request.addHeader("User-Agent", "jumblr/" + this.version);

    return request;
}
 
Example 8
Source File: ResourceClient.java    From jerseyoauth2 with MIT License 5 votes vote down vote up
public String sendTestRequestSample1(Token accessToken) throws ClientException
{
	OAuthService service = getOAuthService(scopes, null);
	
	OAuthRequest request = new OAuthRequest(Verb.GET,
			"http://localhost:9998/testsuite/rest/sample/1");
	service.signRequest(accessToken, request);
	Response response = request.send();
	if (response.getCode()!=200)
		throwClientException(response);
	return response.getBody();
}
 
Example 9
Source File: ResourceClient.java    From jerseyoauth2 with MIT License 5 votes vote down vote up
public String sendTestRequestSample2(Token accessToken) throws ClientException
{
	OAuthService service = getOAuthService(null, null);
	
	OAuthRequest request = new OAuthRequest(Verb.GET,
			"http://localhost:9998/testsuite/rest/sample2/1");
	service.signRequest(accessToken, request);
	Response response = request.send();
	if (response.getCode()!=200)
		throwClientException(response);
	return response.getBody();
}
 
Example 10
Source File: SmugMugInterface.java    From data-transfer-project with Apache License 2.0 4 votes vote down vote up
public InputStream getImageAsStream(String urlStr) {
  OAuthRequest request = new OAuthRequest(Verb.GET, urlStr);
  oAuthService.signRequest(accessToken, request);
  final Response response = request.send();
  return response.getStream();
}
 
Example 11
Source File: GoogleAPI.java    From mamute with Apache License 2.0 4 votes vote down vote up
private Response makeRequest(Token accessToken) {
	OAuthRequest request = new OAuthRequest(Verb.GET, "https://www.googleapis.com/plus/v1/people/me");
	service.signRequest(accessToken, request);
	request.addHeader("GData-Version", "3.0");
	return request.send();
}