Permalink
Browse files

Fix Facebook login, who changed URLs

  • Loading branch information...
1 parent 3c760df commit de9cdcc91ad873ca90735586949a81e4fe61bce0 @apmon committed Jun 10, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 app/controllers/user_controller.rb
@@ -539,14 +539,14 @@ def federated_authentication(identity_url)
def facebook_authentication()
if params[:code]
- consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://graph.facebook.com', :token_url => '/oauth/access_token')
+ consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://graph.facebook.com', :authorize_url => '/dialog/oauth', :token_url => '/oauth/access_token')
access_token = consumer.auth_code.get_token(params[:code], {:redirect_uri => "#{request.protocol}#{request.host_with_port}#{request.fullpath}", :parse => :query})
user_info = access_token.get('/me').parsed
identity_url = "#facebook#://" + user_info["id"]
login_with_identity_url(identity_url, user_info["name"], user_info["email"])
else
session[:federated_auth_method] = 'facebook'
- consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://graph.facebook.com', :token_url => '/oauth/access_token')
+ consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://www.facebook.com/', :authorize_url => '/dialog/oauth', :token_url => '/oauth/access_token')
redirect_to consumer.auth_code.authorize_url(:scope => 'email', :redirect_uri => "#{request.protocol}#{request.host_with_port}#{request.fullpath}")
end
end
@@ -651,15 +651,15 @@ def federated_verify(identity_url, user)
def facebook_verify(identity_url, user)
if params[:code]
- consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://graph.facebook.com', :token_url => '/oauth/access_token')
+ consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://graph.facebook.com', :authorize_url => '/dialog/oauth', :token_url => '/oauth/access_token')
access_token = consumer.auth_code.get_token(params[:code], {:redirect_uri => "#{request.protocol}#{request.host_with_port}#{request.fullpath}", :parse => :query})
user_info = access_token.get('/me').parsed
identity_url = "#facebook#://" + user_info["id"]
user.openid_url = identity_url
yield user, user_info["email"]
else
session[:federated_auth_method] = 'facebook'
- consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://graph.facebook.com', :token_url => '/oauth/access_token')
+ consumer = OAuth2::Client.new(FACEBOOK_APP_ID,FACEBOOK_APP_SHARED_SECRET, :site => 'https://www.facebook.com', :authorize_url => '/dialog/oauth', :token_url => '/oauth/access_token')
redirect_to consumer.auth_code.authorize_url(:scope => 'email', :redirect_uri => "#{request.protocol}#{request.host_with_port}#{request.fullpath}")
end
end

0 comments on commit de9cdcc

Please sign in to comment.