Linked-in Once Authenticated: Authentication is requested again when the user profile Url is called

I am using the LinkedIn-j API to integrate LinkedIn. I can post a status update. I want to show the user profile in a WebView in Android for this. I get the user's public URL using the code below.

 person.getSiteStandardProfileRequest().getUrl(); 

which returns something like this http://www.linkedin.com/profileviewProfile=&key=100652876&authToken=AWW7&authType=name&trk=api*a169149*s177398*

If , I’m going to open this URL in a WebView, and then redirect it to the LinkedIn login page and after filling out the credentials I can see the user profile .

I want to open a user profile without entering credentials, again

I also tried to add

 URL&accesstoken="tokenIdReturned by Application"; 

But I can not directly open the user profile. What am I missing?

+7
source share
1 answer

I had the same requirement, and I did this by doing two things.

First of all . I used my own WebView to load another URL for authentication and profile display. Instead, I used WebView as public static , using the default browser, I redirect calls to my own WebView in my work.

Second I set webview.getSettings().setAppCacheEnabled(true); , so now it does not request a login again when viewing a profile.

I declared my activity as singleInstace in the Manifest.xml file.

UPDATE:

How I used WebView in My Activity.

 public static WebView WV = null; String uri; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv = (TextView) findViewById(R.id.tv); if (WV == null) { WV = (WebView) findViewById(R.id.webView1); WV.getSettings().setJavaScriptEnabled(true); WV.getSettings().setAppCacheEnabled(true); // the important change WV.getSettings().setSupportZoom(true); WV.getSettings().setBuiltInZoomControls(true); } final SharedPreferences pref = getSharedPreferences(OAUTH_PREF, MODE_PRIVATE); final String token = pref.getString(PREF_TOKEN, null); final String tokenSecret = pref.getString(PREF_TOKENSECRET, null); if (token == null || tokenSecret == null) { startAutheniticate(); } else { showCurrentUser(new LinkedInAccessToken(token, tokenSecret)); } } void startAutheniticate() { final LinkedInRequestToken liToken = oAuthService .getOAuthRequestToken(OAUTH_CALLBACK_URL); uri = liToken.getAuthorizationUrl(); getSharedPreferences(OAUTH_PREF, MODE_PRIVATE).edit() .putString(PREF_REQTOKENSECRET, liToken.getTokenSecret()) .commit(); WV.loadUrl(uri); } void showCurrentUser(final LinkedInAccessToken accessToken) { // code to get Profile object using Linkedin-J API //which is already available on the API site as Example WV.loadUrl(profile.getSiteStandardProfileRequest().getUrl()); } 
+5
source

All Articles