Facebook访问令牌出错 [英] Error with facebook access token
问题描述
我要求我的标签应用程序有扩展权限。所以在回调我等待代码参数和access_token。
我从fbgraph官方GIT存储库中提取此代码。
def authorize
begin
@ auth.client.authorization_code = params [:code]
#In access_token行应该返回我access__token但是会抛出一个错误消息(见下文)
access_token = @ auth.client.access_token! #=> Rack :: OAuth2 :: AccessToken
@facebook_user = FbGraph :: User.me(access_token).fetch#=> FbGraph :: User
#MORE CODE WITHOUT IMPORTANCE
redirect_to:controller => dashboard,:action => index
rescue Exception => e
logger.info(e.message)
end
end
抛出此错误消息:
Rack :: OAuth :: Client :: Error#=> @status = 400,Message => Missing redirect uri
请快速帮助我。对不起,谢谢提前
我正在使用类似的fb_graph宝石。为了获取access_token,您还需要提供回调URI - 这是fb_graph版本:
client.redirect_uri = http://your.callback.uri
client.authorization_code = params [:code]
access_token = client.access_token!
更新:
查看fbgraph宝贝文档我想你需要替换这两行:
@ auth.client.authorization_code = params [:code]
access_token = @ auth.client.access_token!
这样:
access_token = @ auth.client.authorization.process_callback(params [:code],:redirect_uri => callback_url)
$ b说实话,我看着使用fbgraph gem,但是文档太糟糕了,所以我转而使用了fb_graph,而这个文件类似,实际上在文档中有一些有用的例子。
My problem is on facebook callback url. I am using fbgraph gem on Rails 3.0.
I ask for extended permissions on my tab application. So in the callback I wait code parameter and access_token.
I extract this code from fbgraph official GIT repository.
def authorize
begin
@auth.client.authorization_code = params[:code]
#In access_token line should return me access__token but throw a error message (see below)
access_token = @auth.client.access_token! # => Rack::OAuth2::AccessToken
@facebook_user = FbGraph::User.me(access_token).fetch # => FbGraph::User
#MORE CODE WITHOUT IMPORTANCE
redirect_to :controller => "dashboard", :action => "index"
rescue Exception => e
logger.info(e.message)
end
end
Throw this error message:
Rack::OAuth::Client::Error # => @status = 400, Message => Missing redirect uri
Please I need help quickly. Excuse me and thanks in advance
I'm using the fb_graph gem which is similar. In order to get the access_token you also need to supply the callback URI - this is the fb_graph version:
client.redirect_uri = "http://your.callback.uri"
client.authorization_code = params[:code]
access_token = client.access_token!
Update:
Looking at the fbgraph gem documentation I think you need to replace these two lines:
@auth.client.authorization_code = params[:code]
access_token = @auth.client.access_token!
With this:
access_token = @auth.client.authorization.process_callback(params[:code], :redirect_uri => callback_url)
To be honest I looked at using the fbgraph gem but the documentation was so bad that I switched to fb_graph instead which is similar and actually has some useful examples in the documentation.
这篇关于Facebook访问令牌出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!