java - Signing in via Twitter OAuth doesn't remember authorization -


i writing web application , have implemented user can sign in via twitter, using spring-social-(core/twitter).

however, twitter behaves strangely. after initial authentication/authorization, every time i'm sending user twitter authentication, twitter prompts authorize application again. i've looked connected twitter profile. app there , authorized correctly (in case read access).

i don't have case of requesting additional permissions. application needs read access (the authorization dialog confirms this).

i using oauth1operations (returned twitterconnectionfactory) oauth dance , save resulting connection in database. front-end written wicket 1.5.

i can work around behavior re-authorizing app again , again when want sign in via twitter, big nuisance. knows i'm missing here?

here code:

twitterconnectionfactory connectionfactory = (twitterconnectionfactory) connectionfactorylocator.getconnectionfactory(twitter.class); string callbackurl = [...];  if (pageparameters.get("oauth_token").isnull() || pageparameters.get("oauth_verifier").isnull()) {     multivaluemap<string, string> params = new linkedmultivaluemap<string, string>();     params.add("x_auth_access_type", "read");     oauthtoken token = connectionfactory.getoauthoperations().fetchrequesttoken(callbackurl, params);      string url = connectionfactory.getoauthoperations().buildauthorizeurl(token.getvalue(), oauth1parameters.none);      getsession().setattribute("twitter_token", token);     setresponsepage(new redirectpage(url)); } else {     string token = pageparameters.get("oauth_token").tostring();     string verifier = pageparameters.get("oauth_verifier").tostring();      oauthtoken previoustoken = (oauthtoken) getsession().getattribute("twitter_token");      if (previoustoken.getvalue().equals(token)) {         authorizedrequesttoken authorizedrequesttoken = new authorizedrequesttoken(previoustoken, verifier);          oauthtoken accesstoken = connectionfactory.getoauthoperations().exchangeforaccesstoken(authorizedrequesttoken, null);         connection<twitter> connection = connectionfactory.createconnection(accesstoken);     } } 

i've found solution! detailed here: simple twitter oauth authorization asking credentials every time

the problem requested twitter authorize app every time. replacing:

string url = connectionfactory.getoauthoperations().buildauthorizeurl(token.getvalue(), oauth1parameters.none); 

with

string url = connectionfactory.getoauthoperations().buildauthenticateurl(token.getvalue(), oauth1parameters.none); 

solves issue! calling url authentication ask authorization if app hasn't been authorized yet.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

jquery - Invalid Assignment Left-Hand Side -

gmail - Is there any documentation for read-only access to the Google Contacts API? -