2

I am using socialauth android for my app. My requirement is to reuse the access token keys and secret previously stored during the authorisation. I am unable to do it in any possible way, even I googled a lot but could not find any way resusing the access tokens for Facebook, twitter, g+ etc. to avoid reauthorisation and reauthentication for next time.

I am getting the token as follows

String token=adapter.getCurrentProvider().getAccessGrant().getKey()

Storing this token in database and I want to use nexr time when user tries to login agsin to avoid the process of re authentication and instead directly user must be able to use this token to perform updatestatus and other functions.

How can I do this?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
darc
  • 41
  • 2
  • Hi , please note once you click signout your token becomes invalid. secondly socialauth-android already saves access token in form of access grant. you need to recreate access grant to reuse it. check source code and see SocialAuthDialog.java. hope it helps – vineet Apr 02 '14 at 08:02
  • but the problem is that I am able to access those stored token from the preferences based on the provider but in that the secret is always null and that is why I am getting nullpointer exception always.... – darc Apr 06 '14 at 07:15
  • Please reply I am stuck with it since long – darc Apr 12 '14 at 05:13

1 Answers1

1

You can try the following

 val socialAuthManager = new SocialAuthManager    
 socialAuthManager.setSocialAuthConfig(socialAuthConfig)    
 val providerId = "linkedin"    
 val linkedinAccessToken = YOUR_TOKEN
 val accessGrant = new AccessGrant();
 accessGrant.setKey(linkedinAccessToken);
 accessGrant.setProviderId(providerId);

 AuthProvider provider = socialAuthManager.connect(accessGrant);

 Profile profile = provider.getUserProfile();
Tarun Nagpal
  • 964
  • 1
  • 9
  • 25