在linkedin插件中使用omniauth的linkedin令牌
我正在使用带有omniauth 插件的Rails 通过LinkedIn 验证我的应用程序。目前,我存储如果用户成功授权应用程序,omniauth 返回的 linkedin 令牌:
oauth_token"=>"9dd623ad-1e21-2cec-9ede-107e1f8e9e18"
我还使用 linkedin获取用户 Linkedin 信息的插件。问题是;该插件需要两个令牌,如下所示:
client.authorize_from_request(rtoken, rsecret, pin)
c.authorize_from_access("OU812", "8675309")
How can I use theomniauth's token in linkedin plugin?有什么想法吗?
I am using Rails with omniauth plugin to authenticate my application via LinkedIn. Currently, I store the linkedin token which omniauth returns if the user successfully authorize the application:
oauth_token"=>"9dd623ad-1e21-2cec-9ede-107e1f8e9e18"
I am also using linkedin plugin to get user's Linkedin information. The problem is; the plugin requires two tokens like the following:
client.authorize_from_request(rtoken, rsecret, pin)
c.authorize_from_access("OU812", "8675309")
How can I use the omniauth's token in linkedin plugin? Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OMNIAUTH 仅用于身份验证。 AFAIK 您将无法单独使用带有该 oauth 令牌的 API。您仍然需要将用户发送到 linkedin 以授权 API 访问,方法如下:
参见此处的示例:
http://pivotallabs.com/users/will/blog/articles/1096-linkedin-gem-for-a-web-app
更新:
我能够重用在 Omniauth 回调中从 LinkedIn 收到的访问令牌和访问密钥,并将其传递给 client.authorize_from_access 并以这种方式访问 LinkedIn API。您的情况可能会有所不同,因为我必须自定义 linked_in gem 以适应我的工作流程,但是一旦 Omniauth 获得访问令牌和秘密,您就不再需要调用 client.authorize_from_request
OMNIAUTH is for Authentication only. AFAIK you wont be able to use the API with that oauth token alone. Youll still need to send the user off to linked in to authorize API access by doing something like
See example here:
http://pivotallabs.com/users/will/blog/articles/1096-linkedin-gem-for-a-web-app
Update:
I was able to reuse access token and access secret that I received upon Omniauth callback from LinkedIn and pass it on to client.authorize_from_access and got access to LinkedIn API that way. Your mileage may vary as I had to customize linked_in gem to fit my workflow a bit, but once Omniauth gets access token and secret you no longer need to call client.authorize_from_request