java - Spring social - Exception while completing OAuth 2 connection: Authorization is required for the operation, -
i composing spring-social. when click / signin / facebook button:
exception while completing oauth 2 connection: org.springframework.social.missingauthorizationexception: authorization required operation, api created without authorization.
i have encountered error.
result of debugging, facebook access token seems received.
an error occurs in part after normal login of facebook.
connectsupport class:
accessgrant accessgrant = connectionfactory.getoauthoperations().exchangeforaccess(code, callbackurl(request), null);
this composition.
socialconfig:
@inject private datasource datasource; @autowired userrepository userrepository; @autowired postsocialsigninadapter postsocialsigninadapter; @override public useridsource getuseridsource() { return new cuseridsource(); } @override public void addconnectionfactories(connectionfactoryconfigurer cfconfig, environment env) { string appkey = "4123213121231231212331"; string appsecret = "512312312lkjj1232kj3l1jl213"; cfconfig.addconnectionfactory(new facebookconnectionfactory(appkey, appsecret)); } @override public usersconnectionrepository getusersconnectionrepository(connectionfactorylocator connectionfactorylocator) { jdbcusersconnectionrepository repository = new jdbcusersconnectionrepository(datasource, connectionfactorylocator, encryptors.nooptext()); repository.setconnectionsignup(new socialimplicitsignup(userrepository)); return repository; } @bean @scope(value = "request", proxymode = scopedproxymode.interfaces) public facebook facebook(connectionrepository repository) { connection<facebook> connection = repository.findprimaryconnection(facebook.class); return connection != null ? connection.getapi() : null; } @bean public providersignincontroller providersignincontroller(connectionfactorylocator connectionfactorylocator, usersconnectionrepository usersconnectionrepository) { providersignincontroller providersignincontroller = new providersignincontroller(connectionfactorylocator, usersconnectionrepository, postsocialsigninadapter); providersignincontroller.setsignupurl("/"); return providersignincontroller; }
userrepository interface
public interface userrepository extends jparepository<user, string> { public user findbyusername(string username); }
error log
error: org.springframework.social.connect.web.providersignincontroller - exception while completing oauth 2 connection: org.springframework.social.missingauthorizationexception: authorization required operation, api binding created without authorization. @ org.springframework.social.facebook.api.impl.abstractfacebookoperations.requireauthorization(abstractfacebookoperations.java:30) @ org.springframework.social.facebook.api.impl.usertemplate.getuserprofile(usertemplate.java:48) @ org.springframework.social.facebook.connect.facebookadapter.setconnectionvalues(facebookadapter.java:42) @ org.springframework.social.facebook.connect.facebookadapter.setconnectionvalues(facebookadapter.java:30) @ org.springframework.social.connect.support.abstractconnection.setvalues(abstractconnection.java:175) @ org.springframework.social.connect.support.abstractconnection.initkey(abstractconnection.java:137) @ org.springframework.social.connect.support.oauth2connection.<init>(oauth2connection.java:75)
i not know how this. please me.
this can related many causes @ first should check spring-social-facebook version. since facebook graph api 2.2 deprecation, spring recommendation change version 2.0.3.release. else talking similar issue here "similar post
don't try 2.0.2.release, afaik there issue inconsistent property type unmapped on json call.
Comments
Post a Comment