Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
onerandomgig opened this issue Nov 28, 2015 · 1 comment

Comments

@onerandomgig
Copy link

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
Copy link
Collaborator

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 [email protected]
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
#68.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants