public void testDummy() {}
public void _testFlow() throws Exception {
enableProxy();
final OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
final OAuthProvider provider = new DefaultOAuthProvider(REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL, AUTHORIZATION_WEBSITE_URL);
System.out.println("Fetching request token...");
final String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
System.out.println("Request token: " + consumer.getToken());
System.out.println("Token secret: " + consumer.getTokenSecret());
System.out.println("Now visit:\n" + authUrl + "\n... and grant this app authorization");
System.out.println("Enter the verification code and hit ENTER when you're done:");
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final String verificationCode = br.readLine();
System.out.println("Fetching access token...");
provider.retrieveAccessToken(consumer, verificationCode.trim());
System.out.println("Access token: " + consumer.getToken());
System.out.println("Token secret: " + consumer.getTokenSecret());
// Subsequent calls to Salesforce will fail if verification code is set
// after getting the access token, so remove it from additional parameters
consumer.setAdditionalParameters(null);
// Salesforce does not use the OAuth token directly for regular API calls.
// You must first make a special login API call to get a serverUrl and sessionId
final URL loginUrl = new URL(SFDC_LOGIN_URL);
final HttpURLConnection request = (HttpURLConnection) loginUrl.openConnection();
request.setRequestMethod("POST");
consumer.sign(request);
System.out.println("Sending request...");
request.connect();
System.out.println("Response: " + request.getResponseCode() + " " + request.getResponseMessage());