Class: OmniAuth::Strategies::Facebook

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/facebook.rb

Constant Summary

DEFAULT_SCOPE =
'email,offline_access'

Instance Method Summary (collapse)

Instance Method Details

- (Object) access_token_options



84
85
86
# File 'lib/omniauth/strategies/facebook.rb', line 84

def access_token_options
  options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
end

- (Object) authorize_params



88
89
90
91
92
93
94
# File 'lib/omniauth/strategies/facebook.rb', line 88

def authorize_params
  super.tap do |params|
    params.merge!(:display => request.params['display']) if request.params['display']
    params.merge!(:state => request.params['state']) if request.params['state']
    params[:scope] ||= DEFAULT_SCOPE
  end
end

- (Object) build_access_token



62
63
64
65
66
# File 'lib/omniauth/strategies/facebook.rb', line 62

def build_access_token
  with_authorization_code { super }.tap do |token|
    token.options.merge!(access_token_options)
  end
end

- (Object) callback_url

NOTE if we're using code from the signed request cookie then FB sets the redirect_uri to '' during the authorize phase + it must match during the access_token phase: github.com/facebook/php-sdk/blob/master/src/base_facebook.php#L348



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/omniauth/strategies/facebook.rb', line 72

def callback_url
  if @authorization_code_from_cookie
    ''
  else
    if options.authorize_options.respond_to?(:callback_url)
      options.authorize_options.callback_url
    else
      super
    end
  end
end

- (Object) raw_info



58
59
60
# File 'lib/omniauth/strategies/facebook.rb', line 58

def raw_info
  @raw_info ||= access_token.get('/me').parsed
end

- (Object) signed_request



96
97
98
99
100
101
# File 'lib/omniauth/strategies/facebook.rb', line 96

def signed_request
  @signed_request ||= begin
    cookie = request.cookies["fbsr_#{client.id}"] and
    parse_signed_request(cookie)
  end
end