Open GoogleCodeExporter opened 9 years ago
I proposed these two change to the implementation to solve the problems
encountered with scope...
1.
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- <html>LinkedInOAuthService.java (Today 18.48.21)</html>
+++ <html>LinkedInOAuthService.java (Today 18.54.32)</html>
@@ -51,6 +51,15 @@
*
* @return the o auth access token
*/
+ public LinkedInAccessToken getOAuthAccessToken(LinkedInRequestToken
requestToken, String scope, String oauthVerifier);
+ /**
+ * Gets the o auth access token.
+ *
+ * @param requestToken the request token
+ * @param oauthVerifier the oauthVerifier
+ *
+ * @return the o auth access token
+ */
public LinkedInAccessToken getOAuthAccessToken(LinkedInRequestToken requestToken, String oauthVerifier);
/**
2.
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- <html>LinkedInOAuthServiceImpl.java (Today 18.48.21)</html>
+++ <html>LinkedInOAuthServiceImpl.java (Today 18.59.30)</html>
@@ -115,12 +115,20 @@
*/
@Override
public LinkedInAccessToken getOAuthAccessToken(LinkedInRequestToken requestToken, String oauthVerifier) {
+ return(getOAuthAccessToken(requestToken, null, oauthVerifier));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public LinkedInAccessToken getOAuthAccessToken(LinkedInRequestToken
requestToken, String scope, String oauthVerifier) {
if (requestToken == null) {
throw new IllegalArgumentException("request token cannot be null.");
}
try {
final OAuthConsumer consumer = getOAuthConsumer();
- final OAuthProvider provider = getOAuthProvider();
+ final OAuthProvider provider = getOAuthProvider(scope);
consumer.setTokenWithSecret(requestToken.getToken(), requestToken.getTokenSecret());
provider.retrieveAccessToken(consumer, oauthVerifier);
@@ -227,7 +235,13 @@
*
*/
protected OAuthProvider getOAuthProvider() {
- DefaultOAuthProvider provider = new
DefaultOAuthProvider(LinkedInApiUrls.LINKED_IN_OAUTH_REQUEST_TOKEN_URL,
+ return(getOAuthProvider(null));
+ }
+ /**
+ *
+ */
+ protected OAuthProvider getOAuthProvider(String scope) {
+ DefaultOAuthProvider provider = new
DefaultOAuthProvider(LinkedInApiUrls.LINKED_IN_OAUTH_REQUEST_TOKEN_URL+(scope!=n
ull)?"?scope="+scope.replace(' ', '+'):"",
LinkedInApiUrls.LINKED_IN_OAUTH_ACCESS_TOKEN_URL, LinkedInApiUrls.LINKED_IN_OAUTH_AUTHORIZE_URL);
provider.setOAuth10a(OAUTH_VERSION_1_0_a.equals(ApplicationConstants.OAUTH_VERSION));
Then use instead of simply:
LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(linkedInApiKey, linkedInSecretKey)
LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken(callbackUrl);
LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(linkedInApiKey, linkedInSecretKey)
LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken(callbackUrl, scope);
The scope is defined with a string like (See
http://oodlestechnologies.com/blogs/Recent-changes-in-LinkedIn-API for more
info)
scope = "r_fullprofile r_network";
Hopes it helps
Original comment by bodh...@gmail.com
on 15 Sep 2012 at 5:07
can you give full sorce code for this so that we can edit, i have downloaded
that, but having some error.
Original comment by deepakch...@gmail.com
on 28 Sep 2012 at 10:42
[deleted comment]
In the methods listed above in the overridden code, it says override
getOAuthAccessToken(), which is incorrect. You need to override
getOAuthRequestToken() and getOAuthRequestToken(callbackurl)...
I was able to get this to work .
I did not modify original source, but what I did was,
1) created my own MyLinkedInOAuthServiceFactory.java ( could not extend theirs
because of constructor error )
2) created my own MyLinkedInOAuthServiceImpl.java - extended from their
LinkedInOAuthServiceImpl
3) created my own MyLinkedInOAuthService.java - extended from their
LinkedInOAuthService
Attached is my source for reference ..
Original comment by abhay.ch...@gmail.com
on 13 Apr 2013 at 9:26
Attachments:
Original issue reported on code.google.com by
dontesto...@gmail.com
on 5 Sep 2012 at 3:39