Twitter login with Spring Social not working -
i have working spring boot app using oauth2 authentication (password grant type). need support facebook , twitter login.
i using custom tokengranter allow client send me facebook access token or twitter consumer id , secret can logged server application , receive oauth2 access_token generate. have working facebook using facebookconnectionfactory
:
connection<facebook> connection = facebookconnectionfactory.createconnection(new accessgrant(providertoken));
with connection, user id of facebook:
string provideruserid = connection.getkey().getprovideruserid();
with id, search if there such user in userrepository
, if so, log in user:
customuserdetails userdetails = new customuserdetails(user); userauth = new socialauthenticationtoken(connection, userdetails, null, userdetails.getauthorities()); securitycontextholder.getcontext().setauthentication(userauth);
this works fine. doing same twitter:
connection<twitter> connection = twitterconnectionfactory.createconnection(new oauthtoken(providertoken, tokensecret));
gives me exception:
unable connect twitter: authorization required operation, api binding created without authorization.
what find strange using twittertemplate
same app id , secret , consumer , consumer secret work.
twittertemplate twittertemplate = new twittertemplate(...); useroperations useroperations = twittertemplate.useroperations(); accountsettings accountsettings = useroperations.getaccountsettings();
i need connection<twitter>
object socialauthenticationtoken
. doing wrong?
stupid mistake, had:
@value("spring.social.twitter.app-id") private string twitterappid; @value("spring.social.twitter.app-secret") private string twitterappsecret;
in stead of:
@value("${spring.social.twitter.app-id}") private string twitterappid; @value("${spring.social.twitter.app-secret}") private string twitterappsecret;
so put literal text spring.social.twitter.app-id
instead of value of property.
Comments
Post a Comment