class FBGraph::Authorization
Public Class Methods
new(client)
click to toggle source
# File lib/fbgraph/authorization.rb, line 5 def initialize(client) @client = client end
Public Instance Methods
process_callback(code, options = {})
click to toggle source
# File lib/fbgraph/authorization.rb, line 15 def process_callback(code, options = {}) # HACK(pwnall): :parse => :query is added because Facebook's tarded OAuth # endpoint returns ContentType: text/plain instead of # application/x-www-form-urlencoded options = { :redirect_uri => FBGraph.config[:canvas_url], :parse => :query }.merge(options) @client.auth = @client.oauth_client.auth_code.get_token(code, options) @client.access_token = @client.auth.token end
upgrade_session!(key)
click to toggle source
# File lib/fbgraph/authorization.rb, line 25 def upgrade_session!(key) token = upgrade_session_keys(key).first @client.access_token = token end
upgrade_session_keys(*keys)
click to toggle source
# File lib/fbgraph/authorization.rb, line 30 def upgrade_session_keys(*keys) tokens = @client.oauth_client.request(:get, '/oauth/exchange_sessions', { :client_id => @client.client_id, :client_secret => @client.secret_id, :type => 'client_cred', :sessions => keys.flatten.join(',') }) JSON.parse(tokens).map { |hash| hash['access_token'] if hash} end