Sha256: 911fbc4fec643ea289d91d5f85e82e2b5b76f037e6d1dc61d665b7ddcd6c5eea
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
module FBGraph class Authorization def initialize(client) @client = client end def authorize_url(params = {}) params = { :redirect_uri => FBGraph.config[:canvas_url] }.merge(params) @client.oauth_client.auth_code.authorize_url(params) end 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 def upgrade_session!(key) token = upgrade_session_keys(key).first @client.access_token = token end 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 end end
Version data entries
5 entries across 5 versions & 1 rubygems