huanghengmin / oauth

Automatically exported from code.google.com/p/oauth
0 stars 0 forks source link

OAuthException: Response body is incorrect. Can't extract token and secret #224

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. http://pastebin.com/T8qMWcfg outh.jsp
2. http://pastebin.com/KE8QCL2t outhcallback.jsp

What is the expected output? What do you see instead?

Expected : 
Token accessToken = service.getAccessToken(requestToken, verifier);
call should have not errors.

Actual : 
org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract 
token and secret from this: 
'oauth_problem=signature_invalid&oauth_problem_advice=com.linkedin.security.auth
.pub.LoginDeniedInvalidAuthTokenException%20while%20obtaining%20request%20token%
20for%20%3APOST%26https%253A%252F%252Fapi.linkedin.com%252Fuas%252Foauth%252Facc
essToken%26oauth_consumer_key%253Di4t7bf5319a5%2526oauth_nonce%253D2295154173%25
26oauth_signature_method%253DHMAC-SHA1%2526oauth_timestamp%253D1335215773%2526oa
uth_token%253Daac2f41f-5d0f-4753-9d4d-2e0c018b64c4%2526oauth_verifier%253D07069%
2526oauth_version%253D1.0%0AOAU%3Ai4t7bf5319a5%7Caac2f41f-5d0f-4753-9d4d-2e0c018
b64c4%7C%2A01%7C%2A01%3A1335215773%3AKbo2ehezgJHlvhVY9TqwecmjnTc%3D'
    at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
    at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
    at org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:82)

What version of the product are you using? On what operating system?
scribe-1.3.0.jar
on App Engine

NOTE: TwitterApi Works without any issues.
Also, I've tried the LinkedInExample and it works. The problem is with the 
callback.

How the outhcallback.jsp works

1. No session is used so I did below code on the callback again.
    service = new ServiceBuilder()
    .provider(LinkedInApi.class)
    .apiKey(OAuthConsumerKey.LINKEDIN_CONSUMER_KEY)
    .apiSecret(OAuthConsumerKey.LINKEDIN_CONSUMER_SECRET)
    .callback(callbackUrl)
    .build();
    requestToken = new Token(oAuthToken,OAuthConsumerKey.LINKEDIN_CONSUMER_SECRET);

Then using the verifier (which I already tested on LinkedInExample)

String oAuthVerifier = request.getParameter("oauth_verifier");
Verifier verifier = new Verifier(oAuthVerifier);

Then just called 
Token accessToken = service.getAccessToken(requestToken, verifier);

Then I got the attached exception.

My question is that, why does it work for Twitter and not in LinkedIn. Is there 
a special way I call Twitter, similar to Facebook API where no token should be 
passed?

And the one I cannot understand is on the Sample the flow is : 
OAuthService service = new ServiceBuilder()
Token requestToken = service.getRequestToken();
Verifier verifier = new Verifier(in.nextLine());
Token accessToken = service2.getAccessToken(requestToken, verifier);

But when I changed the code on did the same : 

I got this instead : 
org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract 
token and secret from this: 'oauth_problem=permission_unknown'
    at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
    at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
    at org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:82)

Original issue reported on code.google.com by iceal.th...@gmail.com on 23 Apr 2012 at 9:44

GoogleCodeExporter commented 8 years ago
Also, I saw a couple of threads while googling. Something involving using 
HmacSHA1, but I cannot figure out where I need to add that on Scribe code.

Original comment by iceal.th...@gmail.com on 23 Apr 2012 at 9:49

GoogleCodeExporter commented 8 years ago
Typo : 

My question is that, why does it work for Twitter and not in LinkedIn. Is there 
a special way to call LinkedIn, similar to Facebook API where no token should 
be passed?

Original comment by iceal.th...@gmail.com on 23 Apr 2012 at 9:51

GoogleCodeExporter commented 8 years ago
i working on grails version 2+ ... and have the same problem .... 
everybody help @@@
this problem here :
Token accessToken = service.getAccessToken(rt, v);

Original comment by thaigiab...@gmail.com on 1 Nov 2012 at 3:32