1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

putting blank redirect_uri to use authorization code included in signed request

ugly hack.
This commit is contained in:
nov 2015-12-13 01:05:31 +09:00
parent 2b86654495
commit daffc1670d
3 changed files with 16 additions and 0 deletions

View file

@ -2,6 +2,7 @@ require 'active_support'
require 'active_support/core_ext' require 'active_support/core_ext'
require 'active_support/concern' require 'active_support/concern'
require 'rack/oauth2' require 'rack/oauth2'
require 'patch/rack/oauth2/util'
module FbGraph2 module FbGraph2
mattr_accessor :root_url, :api_version, :gem_version, :logger, :debugging, :_http_config_, :object_classes mattr_accessor :root_url, :api_version, :gem_version, :logger, :debugging, :_http_config_, :object_classes

View file

@ -27,6 +27,7 @@ module FbGraph2
def instantiate(client) def instantiate(client)
if payload[:code].present? if payload[:code].present?
client.redirect_uri ||= ''
client.authorization_code = payload[:code] client.authorization_code = payload[:code]
self.access_token = client.access_token! self.access_token = client.access_token!
else else

View file

@ -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