English 中文(简体)
在混杂 omni和graph块时,我未能获得关键准入。
原标题:When mixing omniauth and fbgraph gems I am failing to get an access key

I am using Rails 3. I am getting a Rack::OAuth2::Client::Error in SessionsController#create error when I try to get the access key. I used omniauth to login to facebook and I am getting the param["code"] Now I try to use fbgraph to get the access code and I am getting the Rac::OAuth2::Client::Error.

  def create
    auth=request.env["omniauth.auth"]
    fb_auth=FbGraph::Auth.new("xxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxx")
    client=fb_auth.client
    client.redirect_uri="http://localhost:3000/facebook/callback/"
    client.authorization_code=params[:code]
    access_token = client.access_token!  # => Rack::OAuth2::AccessToken
    user=User.find_by_provider_and_uid(auth["provider"], auth["id"]) ||User.create_with_omniauth(auth, access_token)
    session[:user_id]=user.id

    redirect_to root_url, :notice => "Signed In!"
  end

The access_token! 其一行是,该错误正在回归。

问题回答

如果你把转头——寄上 f——而不是客户,那就应当罚款。

fb_auth = FbGraph::Auth.new(
   "xxxxxxx",
   "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
   :redirect_uri = "http://localhost:3000/facebook/callback"
)
client=fb_auth.client
client.authorization_code=params[:code]
access_token = client.access_token!  # => Rack::OAuth2::AccessToken

You should also check out https://github.com/nov/fb_graph/issues/127#issuecomment-2244499, then have a read of the fb_graph_sample code and setup your FbGraph debugging.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签