Proxy Issue for LinkedIn #338

gaoming626 opened this Issue Dec 18, 2012 · 1 comment


None yet

2 participants

When there is no proxy, the Linkedin example works fine.

When there is a proxy, i got an error:

=== LinkedIn's OAuth Workflow ===

Fetching the Request Token...
Exception in thread "main" org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '<script type="text/javascript">
window.onload = function()
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++)
var fields = cookies[i].split('=');
if (fields.length == 2)
var name = fields[0].replace(/\s/g, '');
if (name == 'denial-reason-code')
var reasonCodes = 'Reason codes: ' + fields[1] + '
document.getElementById('denialInfo').innerHTML += reasonCodes;
if (name == 'denial-client-ip')
var ip = 'IP: ' + fields[1] + '
document.getElementById('denialInfo').innerHTML += ip;

<title>999: request failed</title>
  <link rel="stylesheet" type="text/css" href="">

Request denied

Sorry, we are unable to serve your request at this time due to unusual traffic from your network connection.

Please visit our help page and provide the information below for further assistance.

' at org.scribe.extractors.TokenExtractorImpl.extract( at org.scribe.extractors.TokenExtractorImpl.extract( at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken( at com.avaya.smm.linkedin.LinkedInExample.main(

My test example is like following:

package com.avaya.smm.linkedin;
import java.util.Scanner;

import org.scribe.builder.;
import org.scribe.model.
import org.scribe.oauth.*;
public class LinkedInExample
// private static final String PROTECTED_RESOURCE_URL = ",last-name)";
private static final String PROTECTED_RESOURCE_URL = "";

// private static final String PROTECTED_RESOURCE_URL = "";
public static void main(String[] args)

  System.setProperty("https.proxyHost", "");
  System.setProperty("https.proxyPort", "8000");

OAuthService service = new ServiceBuilder()

Scanner in = new Scanner(;

System.out.println("=== LinkedIn's OAuth Workflow ===");

// Obtain the Request Token
System.out.println("Fetching the Request Token...");
Token requestToken = service.getRequestToken();

System.out.println("Got the Request Token!");

System.out.println("Now go and authorize Scribe here:");

System.out.println("And paste the verifier here");

Verifier verifier = new Verifier(in.nextLine());
// Trade the Request Token and Verfier for the Access Token
System.out.println("Trading the Request Token for an Access Token...");
Token accessToken = service.getAccessToken(requestToken, verifier);
System.out.println("Got the Access Token!");
System.out.println("(if your curious it looks like this: " + accessToken + " )");
// Now let's go and ask for a protected resource!
System.out.println("Now we're going to access a protected resource...");
OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
service.signRequest(accessToken, request);
Response response = request.send();
System.out.println("Got it! Lets see what we found...");

System.out.println("Thats it man! Go and build something awesome with Scribe! :)");

//get all the headers
System.out.println("Request headers: " + request.getHeaders().toString());
System.out.println("Response headers: " + response.getHeaders().toString());

// get the url requested
System.out.println("Original location is: " + request.getHeaders().get("content-location"));

// Date of response
System.out.println("The datetime of the response is: " + response.getHeader("Date"));

// Format of the reponse
System.out.println("Format is: " + response.getHeader("x-li-format"));

// Content-type of the response
System.out.println("Content type is: " + response.getHeader("Content-Type") + "\n\n");




Configure the proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment