diff --git a/lib/fb_graph2.rb b/lib/fb_graph2.rb index f5cc9be..f41a679 100644 --- a/lib/fb_graph2.rb +++ b/lib/fb_graph2.rb @@ -2,6 +2,7 @@ require 'active_support' require 'active_support/core_ext' require 'active_support/concern' require 'rack/oauth2' +require 'patch/rack/oauth2/util' module FbGraph2 mattr_accessor :root_url, :api_version, :gem_version, :logger, :debugging, :_http_config_, :object_classes diff --git a/lib/fb_graph2/auth/signed_request.rb b/lib/fb_graph2/auth/signed_request.rb index e1451b5..8754956 100644 --- a/lib/fb_graph2/auth/signed_request.rb +++ b/lib/fb_graph2/auth/signed_request.rb @@ -27,6 +27,7 @@ module FbGraph2 def instantiate(client) if payload[:code].present? + client.redirect_uri ||= '' client.authorization_code = payload[:code] self.access_token = client.access_token! else diff --git a/lib/patch/rack/oauth2/util.rb b/lib/patch/rack/oauth2/util.rb new file mode 100644 index 0000000..4834015 --- /dev/null +++ b/lib/patch/rack/oauth2/util.rb @@ -0,0 +1,14 @@ +# NOTE: Authorization code given via FB JS SDK needs blank string as redirect_uri +module Rack::OAuth2::Util + class << self + def compact_hash_with_blank_redirect_uri(hash) + original_redirect_uri = hash[:redirect_uri] + result = compact_hash_without_blank_redirect_uri hash + if original_redirect_uri + result[:redirect_uri] ||= original_redirect_uri + end + result + end + alias_method_chain :compact_hash, :blank_redirect_uri + end +end \ No newline at end of file