所以我使用Omniauth向Twitter和Foursquare之类的网站进行身份验证。Twitter运行良好,但Foursquare似乎不会返回秘密。
有人知道哪里出问题了吗?
这是控制器中的create操作,Foursquare将用户传回给它,但正如我所说的,它没有获得秘密,只是得到了令牌
def create
omniauth = request.env["omniauth.auth"]
unless current_user.authentications.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
current_user.apply_omniauth(omniauth)
current_user.save
end
flash[:notice] = "Authentication Successfull"
redirect_to authentications_url
end下面是应用omniauth方法:
def apply_omniauth(omniauth)
authentications.build(
:provider => omniauth['provider'],
:uid => omniauth['uid'],
:token => omniauth['credentials']['token'],
:secret => omniauth['credentials']['secret']
)
end发布于 2012-02-12 13:09:30
Foursquare不应该传回密钥,而应该只传回令牌。当你在他们的开发者站点上注册你的应用程序时,foursquare会向你提供foursquare api密钥和密钥。您必须在omniauth.rb中使用这些值
发布于 2012-02-15 00:49:23
Twitter使用Oauth 1.0,foursquare使用2.0
这可能是你的问题所在
https://stackoverflow.com/questions/9192402
复制相似问题