3pillarlabs / socialauth

Java Library for authentication, getting profile, contacts and updating status on Google, Yahoo, Facebook, Twitter, LinkedIn, and many more providers.
https://3pillarlabs.github.io/socialauth/
MIT License
249 stars 141 forks source link

Unable to login to twitter if SocialAuthManager is not persisted in Session (For stateless server implementations) #68

Open onerandomgig opened 8 years ago

onerandomgig commented 8 years ago

Hi,

My server implementation is completely stateless (I am using Dropwizard). I am unable to login to Twitter because of this.

For Facebook, I am able to do this by recreating the accessGrant and then connecting the AuthProvider.

accessGrant = lAuthManager.createAccessGrant(providerId, authorizationCode, lRedirectUrl); AuthProvider provider = lAuthManager.connect(accessGrant);

Where, providerId = facebook authorizationCode = access token from facebook lRedirectUrl = the url to redirect to after successful authentication

However, for twitter, this doesnt work. I have to recreate the accessGrant using the params map

accessGrant = lAuthManager.createAccessGrant(providerId, lParams, lRedirectUrl);

Where, providerId = twitter lParams = Parameter map consisting of requestToken (oauth_token) and oauth_verifier lRedirectUrl = callback URL

It looks like OAuth1 implementation is stateful and requires SocialAuthManager to be persisted to the session.

I created a Stateless implementation of OAuth1 here - https://github.com/onerandomgig/socialauth/blob/master/socialauth/src/main/java/org/brickred/socialauth/oauthstrategy/StatelessOAuth1.java

and updated the TwitterImpl to use this instead, https://github.com/onerandomgig/socialauth/blob/master/socialauth/src/main/java/org/brickred/socialauth/provider/TwitterImpl.java

I have tested it and it works as expected. Could you please let me know if this works and can be integrated into the main branch.

I have also updated the FacebookImpl to use the latest FB API version - 2.5 https://github.com/onerandomgig/socialauth/blob/master/socialauth/src/main/java/org/brickred/socialauth/provider/FacebookImpl.java

Thanks Prashanth

abhinav-maheshwari commented 8 years ago

Thanks Prashanth,

Looks good to me. Could you please send a pull request ?

Warm regards Abhinav

On Sat, Nov 28, 2015 at 9:14 AM, onerandomgig notifications@github.com wrote:

Hi,

My server implementation is completely stateless (I am using Dropwizard). I am unable to login to Twitter because of this.

For Facebook, I am able to do this by recreating the accessGrant and then connecting the AuthProvider.

accessGrant = lAuthManager.createAccessGrant(providerId, authorizationCode, lRedirectUrl); AuthProvider provider = lAuthManager.connect(accessGrant);

Where, providerId = facebook authorizationCode = access token from facebook lRedirectUrl = the url to redirect to after successful authentication

However, for twitter, this doesnt work. I have to recreate the accessGrant using the params map

accessGrant = lAuthManager.createAccessGrant(providerId, lParams, lRedirectUrl);

Where, providerId = twitter lParams = Parameter map consisting of requestToken (oauth_token) and oauth_verifier lRedirectUrl = callback URL

It looks like OAuth1 implementation is stateful and requires SocialAuthManager to be persisted to the session.

I created a Stateless implementation of OAuth1 here - https://github.com/onerandomgig/socialauth/blob/master/socialauth/src/main/java/org/brickred/socialauth/oauthstrategy/StatelessOAuth1.java

and updated the TwitterImpl to use this instead,

https://github.com/onerandomgig/socialauth/blob/master/socialauth/src/main/java/org/brickred/socialauth/provider/TwitterImpl.java

I have tested it and it works as expected. Could you please let me know if this works and can be integrated into the main branch.

I have also updated the FacebookImpl to use the latest FB API version - 2.5

https://github.com/onerandomgig/socialauth/blob/master/socialauth/src/main/java/org/brickred/socialauth/provider/FacebookImpl.java

Thanks Prashanth

— Reply to this email directly or view it on GitHub https://github.com/3pillarlabs/socialauth/issues/68.