[英]How to get omniauth hash if I already have the access_token?
Currently I have it implemented like so. 目前,我已经像这样实现了。
def auth_hash
url = URI.parse('https://graph.facebook.com/me')
url.query = URI.encode_www_form('access_token' => @token, 'fields' => 'email, name, first_name, last_name, gender')
req = Net::HTTP::Get.new url.request_uri
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = nil
http.start do |get|
response = get.request(req)
end
response
end
My IOS app does the callbacks and sends the access token to authenticated with our server. 我的IOS应用程序执行回调,并将访问令牌发送到已通过我们的服务器验证的身份。
I use the method above and it returns the hash from the graph api and I get the user info perfectly. 我使用上面的方法,它从图形api返回哈希值,并且可以完美地获得用户信息。
This method that I've used but it's not utilizing omniauth. 我曾经使用过这种方法,但是没有利用omniauth。 So my question is there a way to retrieve the omniauth hash using only the generated access_token (the token is generated by the facebook sdk and sends it to the server)?
所以我的问题是有一种方法可以仅使用生成的access_token(令牌由facebook sdk生成并将其发送到服务器)来检索omniauth哈希吗?
I'm just trying to make sure I'm not reinventing the wheel using this method. 我只是想确保我不会使用这种方法重新发明轮子。
There are few ruby gems for authentication with Facebook and retrieving data from it. 很少有红宝石可以通过Facebook进行身份验证并从中检索数据。
Please refer this link : https://github.com/arsduo/koala , https://github.com/nov/fb_graph2 请参考此链接: https : //github.com/arsduo/koala,https : //github.com/nov/fb_graph2
And for google use can use refer this link: https://github.com/zquestz/omniauth-google-oauth2 对于Google,可以使用此链接: https : //github.com/zquestz/omniauth-google-oauth2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.