Facebook Oauth integration isssue
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) end
def facebook redirect_to client.auth_code.authorize_url( :redirect_uri => redirect_uri, :scope => 'email,offline_access' ) end
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 end
def redirect_uri uri = URI.parse(request.url) uri.path = '/auth/facebook_callback' uri.query = nil uri.to_s end
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 ???