Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

ruby on rails 3 - #_=_ added to URL by facebook

After connecting to my Rails app via Facebook I have #_=_ added on to my URL.

I tried specifying a redirect_uri as specified by FB but it didn't work.
Javascript workaround to remove the symbols doesn't help. I tried everything with no results.
Any pointers on how to solve this?

My setup:

gem 'rails', '3.0.11'
gem "devise", '1.5.2'
gem "omniauth", '1.0.1'
gem 'omniauth-facebook', '1.0.0rc2'

module Facebook
 CONFIG = YAML.load_file(Rails.root.join("config/facebook.yml"))[Rails.env]
 FB_APP_ID = CONFIG['app_id']
 FB_APP_SECRET = CONFIG['secret_key']
end

Rails.application.config.middleware.use OmniAuth::Builder do    
 provider :facebook, Facebook::FB_APP_ID, Facebook::FB_APP_SECRET,
 :scope => 'offline_access, email, publish_stream',
 :display => 'touch'
end
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The #_=_ fragment is being intentionally added by Facebook as described under Change in Sessions Redirect Behavior. Explicitly setting the redirect_uri in your request allegedly takes care of this problem, but there's apparently a bug that persists the unwanted fragment even when the redirect_uri is specified.

Assuming this bug isn't resolved, a workaround may be to replace the hash location using Javascript:

window.location.hash = ""

This doesn't replace the actual hash character, but will get rid of everything following it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...