java - scribe 1.3 share request to linkedin API return a 401 - unauthorized -
i'm trying send share content linkedin web application, looks i'm doing wrong.
this java code:
string payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+ "<share>" + "<comment>testing</comment>" + "<visibility><code>anyone</code></visibility>" + "</share>"; string protected_resource_url = "http://api.linkedin.com/v1/people/~/shares"; oauthservice service = new servicebuilder() .provider(linkedinapi.class) .apikey("xxxxxxxxx") .apisecret("xxxxxxxxx") .debug() .build(); scanner in = new scanner(system.in); token requesttoken = service.getrequesttoken(); // here enter confirmation code while i'm use oob, use callback in future system.out.println("now go , authorize scribe here:"); system.out.println(service.getauthorizationurl(requesttoken)); system.out.println("and paste verifier here"); system.out.print(">>"); verifier verifier = new verifier(in.nextline()); token accesstoken = service.getaccesstoken(requesttoken, verifier); oauthrequest request = new oauthrequest(verb.post, protected_resource_url); request.addpayload(payload); service.signrequest(accesstoken, request); response response = request.send();
all looked worked in debug console when try print response body this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <error> <status>401</status> <timestamp>1341657286653</timestamp> <request-id>4stp3fugsg</request-id> <error-code>0</error-code> <message>[unauthorized]. oau:xxxxxxx|3619482b-ea17-4382-8008-5b108e90c4a2|*01|*01:1341657286:wp7see6fapij5cskfd3t+lzfwpe=</message> </error>
how can fix this?
thanks pablo, debug mode no me in case, search find issue :
add header post requests
request.addheader("content-length", integer.tostring(payload.length())); request.addheader("content-type", "text/xml");
Comments
Post a Comment