OAuthRequest request = OAuthRequest(Verb.GET, "http://api.twitter.com/1/direct_messages.json"); service.signRequest(accessToken, request); Response response = request.send();
OAuthService service = new ServiceBuilder() .provider(TradeKingAPI.class) .signatureType(QueryString) .apiKey("My consumer key") .apiSecret("My secret") .scope("API.Public") .build(); Token requestToken = service.getRequestToken(); //make your API calls OAuthRequest request = new OAuthRequest(Verb.GET, "http://api.viagogo.net/Public/Event/235"); service.signRequest(requestToken, request); Response response = request.send(); System.out.println(response.getBody());
OAuthService service = new ServiceBuilder() .provider(TradeKingAPI.class) .signatureType(QueryString) .apiKey("My consumer key") .apiSecret("My secret") .scope("API.Public") .build(); Token requestToken = service.getRequestToken(); //make your API calls OAuthRequest request = new OAuthRequest(Verb.GET, "http://api.viagogo.net/Public/Event/235"); service.signRequest(requestToken, request); Response response = request.send(); System.out.println(response.getBody());
OAuthRequest request = new OAuthRequest(Verb.GET, ... //since you're just passing Oauth parameters and nothing else, //you can use signRequest will create Oauth Parameters for you service.signRequest(OAuthConstants.EMPTY_TOKEN, request) Response response = request.send()
OAuthRequest resourceRequest = new OAuthRequest(Verb.GET, RESOURCE_URL); service.signRequest(accessToken, resourceRequest); Response resourceResponse = resourceRequest.send(); JsonObject jsonObject = JsonObject.readFrom(resourceResponse.getBody()); JsonValue value = jsonObject.get("username");
OAuthRequest request = new OAuthRequest(Verb.GET,"http://api.twitter.com/1/statuses/user_timeline.json"); service.signRequest(accessToken, request); Response response = request.send(); System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getBody());
OAuthConfig authConfig = new OAuthConfig("CONSUMER_KEY", "CONSUMER_SECRET", null, SignatureType.Header, null, null); Token token = new Token("TOKEN_ID", "TOKEN_SECRET"); OAuth10aServiceImpl auth10aServiceImpl = new OAuth10aServiceImpl(new NetSuiteApi(), authConfig); OAuthRequest request = new OAuthRequest(Verb.GET, "RESTLET_URL"); request.setRealm("NS_ACCOUNT_ID"); auth10aServiceImpl.signRequest(token, request); Response response = request.send();
// getting user profile OAuthService service = new ServiceBuilder() .provider(FacebookApi.class) .apiKey(YOUR_API_KEY) .apiSecret(YOUR_API_SECRET) .build(); OAuthService service = facebookServiceProvider.getService(); OAuthRequest oauthRequest = new OAuthRequest(Verb.GET, "https://graph.facebook.com/v2.2/me"); //See how this link is appended with v2.2 path!!! service.signRequest(accessToken, oauthRequest); Response oauthResponse = oauthRequest.send(); System.out.println(oauthResponse.getBody());
String accessTokenAlreadyHave = "..."; OAuth2AccessToken accessToken = new OAuth2AccessToken(accessTokenAlreadyHave); // Now let's go and ask for a protected resource! System.out.println("Now we're going to access a protected resource..."); final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL, service); service.signRequest(accessToken, request); final Response response = request.send(); System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getCode()); System.out.println(response.getBody()); System.out.println();
OAuthRequest orequest = new OAuthRequest(Verb.GET, "http://vimeo.com/api/rest/v2"); orequest.addQuerystringParameter("method", "vimeo.test.null"); Response send = orequest.send(); System.out.println(send.getBody());
if(Global.TOKEN_AUTHORIZED != null) { OAuthRequest request = new OAuthRequest(Verb.POST, url); request.addHeader("Content-Type", "application/json"); request.addPayload(params[0]); Global.OAUTH_SERVICE.signRequest(Global.TOKEN_AUTHORIZED, request); response = request.send(); }
OAuthRequest request = new OAuthRequest(Verb.POST, "http://server.example.com/token"); request.addBodyParameter("grant_type", "refresh_token"); request.addBodyParameter("refresh_token", accessToken.getToken()); // were accessToken is the Token object you want to refresh. request.send();
final OAuth20Service service = util.getService(); final OAuthRequest request = new OAuthRequest(Verb.POST, url, service); request.addHeader("Content-Type", "application/json;charset=UTF-8"); request.addPayload(MAPPER.writeValueAsString(requestModel)); // or this if you have a json string // request.addPayload(json); service.signRequest(new OAuth2AccessToken(accessToken), request); final Response postResponse = request.send();
public static String shortenUrl(String longUrl) { @SuppressWarnings("unused") OAuthService oAuthService = new ServiceBuilder().provider(GoogleApi.class).apiKey("anonymous").apiSecret("anonymous") .scope("https://www.googleapis.com/auth/urlshortener") .build(); OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, "https://www.googleapis.com/urlshortener/v1/url"); oAuthRequest.addHeader("Content-Type", "application/json"); String json = "{\"longUrl\": \"http://"+longUrl+"/\"}"; oAuthRequest.addPayload(json); Response response = oAuthRequest.send(); Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType(); Map<String, String> responseMap = new GsonBuilder().create().fromJson(response.getBody(), typeOfMap); String st=responseMap.get("id"); return st; }
public String search(String term, double latitude, double longitude) { OAuthRequest request = new OAuthRequest(Verb.GET, "http://api.yelp.com/v2/search"); request.addQuerystringParameter("term", term); request.addQuerystringParameter("ll", latitude + "," + longitude); this.service.signRequest(this.accessToken, request); Response response = request.send(); return response.getBody(); }
OAuthService service = new ServiceBuilder() .apiKey(APIKEY) .apiSecret(SECRETKEY) .provider(LinkedInApi.class) .build(); OAuthRequest oAuthRequestData = new OAuthRequest(Verb.GET, DATAENDPOINT); oAuthRequestData.addHeader("x-li-format", "json"); Token accessToken = new Token(oauth_token, oauth_token_secret); service.signRequest(accessToken, oAuthRequestData); Response oAuthResponse = oAuthRequestData.send(); System.outt.println(oAuthResponse.getBody());
OAuthRequest request = new OAuthRequest(Verb.POST,"https://accounts.google.com/o/oauth2/token"); request.addBodyParameter("grant_type", "refresh_token"); request.addBodyParameter("refresh_token", accessToken.getToken()); // were accessToken is the Token object you want to refresh. request.addBodyParameter("client_id", your clientID); request.addBodyParameter("client_secret", your clientSecret); Response response = request.send();
String consumerKey = "XXXX"; //api key String consumerSecret = "XXXX"; //api secret String requestUrl = "your context.io request url"; OAuthService service = new ServiceBuilder() .provider(OAuthProvider.class) .apiKey(consumerKey) .apiSecret(consumerSecret) .build(); OAuthRequest request = new OAuthRequest(Verb.GET, requestUrl); Token accessToken = new Token("", ""); //not required for context.io service.signRequest(accessToken, request); Response response = request.send(); Log.d("OAuthTask",response.getBody());
String account_id = "your account id"; String consumerkey = "your contextio consumer key"; String consumersecret = "your contextio consumer secret"; link="https://api.context.io/2.0/accounts/" + account_id + "/messages"; OAuthService service = new ServiceBuilder() .provider(OAuthProvider.class) .apiKey(consumerKey) .apiSecret(consumerSecret) .build(); OAuthRequest request = null; request = new OAuthRequest(Verb.GET, link); Token accessToken = new Token("", ""); service.signRequest(accessToken, request); Response response = request.send(); String b = response.getBody(); Log.d("OAuthTask",response.getBody());
private SocialUser getAccount(OAuth20Service service, OAuth2AccessToken accessToken) { try { OAuthRequest request = new OAuthRequest(Verb.GET, getAccountUrl, service); service.signRequest(accessToken, request); Response response = request.send(); return toAccount(response.getBody()); } catch (Exception e) { return null; } }