1
我正在使用Sinatra和OmniAuth尝试使用Facebook进行身份验证。一切似乎都正常工作,除了昵称属性。我的授权哈希正在为昵称返回一些内容,但它不是该人的昵称。对于我想要做的事,获取这个人的昵称是非常重要的。而且我已经检查了我的Facebook页面,以确保我有一个昵称集,而我确实。它应该返回“HeroicEric”。OmniAuth Facebook身份验证昵称返回“profile.php?id = ..”
get '/auth/:name/callback' do
auth = request.env["omniauth.auth"]
user = User.first_or_create({ :uid => auth["uid"]}, {
:uid => auth["uid"],
:username => auth["user_info"]["nickname"],
:name => auth["user_info"]["name"],
:email => auth["user_info"]["email"]
})
session[:user_id] = user.id
redirect '/user/' + user.id.to_s
end
正在被退回看起来像这样的哈希:
"user_info"=>{
"name"=>"Eric Kelly",
"urls"=>
{
"Facebook"=>"http://www.facebook.com/profile.php?id=550432081",
"Website"=>nil
},
"nickname"=>"profile.php?id=550432081",
"last_name"=>"Kelly",
"image"=>"http://graph.facebook.com/550432081/picture?type=square",
"first_name"=>"Eric",
"email"=>"[email protected]"
},
这听起来很不错。 [rstat.us](http://rstat.us)发现了同样的问题。我们现在查找包含profile.php的用户名,并显示用户输入新用户名的HAML模板。 – 2011-05-04 16:14:32
OmniAuth修复了此问题。 – HeroicEric 2011-06-11 19:55:06