ruby on rails - bad URL request with Koala -
there's problem implementation of koala rails causes send dialogs bug out because site's urls considered invalid facebook.
here happens:
1) when include url such herokuapp-japanized-tree-url/restaurants/2 in send dialog, facebook api considers invalid.(api error 100)
2) debugged urls , indeed there error in them when access remotely, facebook's api verify validity of links. happens during remote attempt , not when user travels page.
3) i've identified weak point in code , has koala:
def set_access_token begin session['fb_cookie'] ||= koala::facebook::oauth.new.get_user_info_from_cookie(cookies) @access_token = session['fb_cookie']["access_token"] rescue koala::facebook::oauthtokenrequesterror session['fb_cookie'] = nil set_access_token end the problem @access_token stays nil regardless of whether existed before. think has cookies not being set when remote request made on server - goes nil.
here log states error in heroku logs - matches point in code showed right above sentence:
2013-04-06t07:59:25+00:00 app[web.1]: processing sessioncontroller#home */* 2013-04-06t07:59:25+00:00 app[web.1]: 2013-04-06t07:59:25+00:00 app[web.1]: nomethoderror (undefined method `[]' nil:nilclass): 2013-04-06t07:59:25+00:00 app[web.1]: app/helpers/session_helper.rb:18:in `set_access_token' 2013-04-06t07:59:25+00:00 app[web.1]: app/helpers/session_helper.rb:58:in `parse_facebook_cookies' 2013-04-06t07:59:25+00:00 app[web.1]: app/helpers/session_helper.rb:63:in `authenticate' 2013-04-06t07:59:25+00:00 app[web.1]: 2013-04-06t07:59:25+00:00 app[web.1]: 2013-04-06t07:59:25+00:00 app[web.1]: completed 500 internal server error in 0ms 2013-04-06t07:59:25+00:00 heroku[router]: at=info method=get path=/home host=powerful-woodland-3700.herokuapp.com fwd="173.252.101.112" dyno=web.1 connect=1ms service=15ms status=500 bytes=643
the key here that, when fb remotely pings url, doesn't activate javascript sdk sets cookies koala taps into.
i have developed different authentification method, first attempt failed , instead set following line in controller:
rescue_from nomethoderror, :with => :redirect_to_signin i think capture random errors expired or destroyed cookies , variety of other unforeseeable events, , redirect user login page.
any thoughts on above welcome.
Comments
Post a Comment