Facebook Oauth integration isssue #66

mabid opened this Issue Aug 16, 2011 · 2 comments

3 participants


Had a few issue getting it to work with facebook, may be i am doing something wrong.

def client
@client ||= OAuth2::Client.new('XXXXXX, 'XXXXX',
:token_url => "/oauth/access_token", :site => 'https://graph.facebook.com', :raise_errors => false)

def facebook
redirect_to client.auth_code.authorize_url(
:redirect_uri => redirect_uri,
:scope => 'email,offline_access'

def facebook_callback
puts params[:code]
access_token = client.auth_code.get_token(params[:code], :parse => :query, :redirect_uri => redirect_uri)
access_token.options[:mode] = :query
access_token.options[:param_name] = "access_token"
access_token.options[:header_format] = ""
puts access_token.inspect
render :json => access_token.get('/me').body

def redirect_uri
uri = URI.parse(request.url)
uri.path = '/auth/facebook_callback'
uri.query = nil

My Question is why do i have to set access_token options once i get it.. it does not work without it. there should be a way to set these options when we create the client object... options like mode param_name and header etc... this doest not make sense to me as a good API...

Any comments.. or may be i dont know oauth2 that well. I tried going through the code.. but this is the only way i could figure out. am i doing something wrong here ???


The get_token method takes a second hash of arguments that it passes along to the access_token upon creation.

  {:parse => :query, :redirect_uri => redirect_uri},
  {:mode => :query, :param_name => "access_token", :header_format => ""}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment