Ruby on rails Omniauth和Foursquare不工作
因此,我使用Omniauth对Twitter和Foursquare等进行身份验证。推特运行良好,但Foursquare似乎没有返回一个秘密 有人知道怎么回事吗 这是控制器中的创建操作,Foursquare正在将用户传递回它,但正如我所说的,它没有得到秘密,只是得到令牌Ruby on rails Omniauth和Foursquare不工作,ruby-on-rails,omniauth,foursquare,Ruby On Rails,Omniauth,Foursquare,因此,我使用Omniauth对Twitter和Foursquare等进行身份验证。推特运行良好,但Foursquare似乎没有返回一个秘密 有人知道怎么回事吗 这是控制器中的创建操作,Foursquare正在将用户传递回它,但正如我所说的,它没有得到秘密,只是得到令牌 def create omniauth = request.env["omniauth.auth"] unless current_user.authentications.find_by_provider_and
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
以下是apply omniauth方法:
def apply_omniauth(omniauth)
authentications.build(
:provider => omniauth['provider'],
:uid => omniauth['uid'],
:token => omniauth['credentials']['token'],
:secret => omniauth['credentials']['secret']
)
end
Foursquare不应该传回秘密,而应该传回令牌。foursquare api密钥和密码由foursquare在开发者网站上注册应用程序时提供给您。您必须在omniauth中使用这些值。rbTwitter使用Oauth 1.0,foursquare使用2.0
这可能是你的问题完成了。我不认为这是必要的,因为它是基本代码,Twitter可以很好地使用它。如果没有您的omniauth版本,以及您得到的错误代码,很难进行诊断。我相信是最新的omniauth,2.0.1。这就是重点,不过我没有得到错误代码。Foursquare说它工作得很好,Omniauth说它工作得很好,但是auth的秘密没有被传回。