java - Facebook OAuth redirect_uri Issue -
i trying build authentication flow in our app facebook in java. using facebook4j library.
my corresponding code follows -
public string authenticate() throws ioexception { facebook facebook = new facebookfactory().getinstance(); string redirecturl = facebook.getoauthauthorizationurl("http://localhost:9099/default/facebook/verify.html"); servletresponse.sendredirect(redirecturl); return null; } public string verify() throws exception { string code = servletrequest.getparameter("code"); facebook facebook = new facebookfactory().getinstance(); accesstoken accesstoken = facebook.getoauthaccesstoken(code); string token = accesstoken.gettoken(); servletresponse.getwriter().write(token); return null; }
i getting error after redirection on line -
accesstoken accesstoken = facebook.getoauthaccesstoken(code);
the error follows -
facebookexception{statuscode=400, errortype='oauthexception', errormessage='redirect_uri isn't absolute uri. check rfc 3986.', errorcode=191, errorsubcode=-1, version=2.2.2} @ facebook4j.internal.http.httpclientimpl.request(httpclientimpl.java:179) @ facebook4j.internal.http.httpclientwrapper.request(httpclientwrapper.java:65) @ facebook4j.internal.http.httpclientwrapper.get(httpclientwrapper.java:97) @ facebook4j.auth.oauthauthorization.getoauthaccesstoken(oauthauthorization.java:107)
redirecturl getting facebook in first call -
tried without using encoding -
it redirecting 'verify' having url -
facebook4j.properties
oauth.appid=416xxxxxxxxx389 oauth.appsecret=9ed3xxxxxxb6acxxxxxxxxc7acxxxx5 oauth.permissions=email,public_profile,user_friends
my facebook app basic settings -
the important advanced settings -
i totally aware similar question has been posted earlier multiple times. have gone through every question & tried suggested resolve issue. due reason not working. decided post problem here after spending 3 days on same issue.
i highly appreciate if points out going wrong.
the redirect_uri
parameter has specified when exchanging code token (and has same specified earlier in login dialog call).
i’d assume since using new facebookfactory().getinstance()
in second method, not case. take @ basic implementation here, https://github.com/roundrop/facebook4j-oauth-example/tree/master/src/main/java/facebook4j/examples/signin
in signinservlet
, facebook object instance stored session, , in callbackservlet
same instance retrieved , used again. therefor, still holds redirect_uri
value used when auth dialog called, , re-use same value when exchanging code
token.
Comments
Post a Comment