Java Code Examples for oauth.signpost.exception.OAuthException#printStackTrace()
The following examples show how to use
oauth.signpost.exception.OAuthException#printStackTrace() .
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: BurpExtender.java From burp-oauth with MIT License | 6 votes |
@Override public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) { if (messageIsRequest && shouldSign(messageInfo)) { HttpRequest req = new BurpHttpRequestWrapper(messageInfo); OAuthConsumer consumer = new DefaultOAuthConsumer( OAuthConfig.getConsumerKey(), OAuthConfig.getConsumerSecret()); consumer.setTokenWithSecret(OAuthConfig.getToken(), OAuthConfig.getTokenSecret()); try { consumer.sign(req); } catch (OAuthException oae) { oae.printStackTrace(); } } }
Example 2
Source File: OAuthClient.java From java-upwork with Apache License 2.0 | 5 votes |
/** * Get access token-secret pair * * @param verifier OAuth verifier, which was got after authorization * @return Access token-secret pair * */ public HashMap<String, String> getAccessTokenSet(String verifier) { try { mOAuthProvider.retrieveAccessToken(mOAuthConsumer, verifier); } catch (OAuthException e) { e.printStackTrace(); } return setTokenWithSecret(mOAuthConsumer.getToken(), mOAuthConsumer.getTokenSecret()); }
Example 3
Source File: OAuthClient.java From java-upwork with Apache License 2.0 | 5 votes |
/** * Get authorization URL, use provided callback URL * * @param oauthCallback URL, i.e. oauth_callback * @return URL for authorizing application * */ private String _getAuthorizationUrl(String oauthCallback) { String url = null; try { url = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, oauthCallback); } catch (OAuthException e) { e.printStackTrace(); } return url; }
Example 4
Source File: OAuthClient.java From java-upwork with Apache License 2.0 | 4 votes |
/** * Send signed POST OAuth request * * @param url Relative URL * @param type Type of HTTP request (HTTP method) * @param params Hash of parameters * @throws JSONException If JSON object is invalid or request was abnormal * @return {@link JSONObject} JSON Object that contains data from response * */ private JSONObject sendPostRequest(String url, Integer type, HashMap<String, String> params) throws JSONException { String fullUrl = getFullUrl(url); HttpPost request = new HttpPost(fullUrl); switch(type) { case METHOD_PUT: case METHOD_DELETE: // assign overload value String oValue; if (type == METHOD_PUT) { oValue = "put"; } else { oValue = "delete"; } params.put(OVERLOAD_PARAM, oValue); case METHOD_POST: break; default: throw new RuntimeException("Wrong http method requested"); } // doing post request using json to avoid issue with urlencoded symbols JSONObject json = new JSONObject(); for (Map.Entry<String, String> entry : params.entrySet()) { json.put(entry.getKey(), entry.getValue()); } request.setHeader("Content-Type", "application/json"); try { request.setEntity(new StringEntity(json.toString())); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // sign request try { mOAuthConsumer.sign(request); } catch (OAuthException e) { e.printStackTrace(); } return UpworkRestClient.getJSONObject(request, type, params); }