【问题标题】:Using omniauth-linkedin for educations, skills, connections使用omniauth-linkedin 进行教育、技能、联系
【发布时间】:2023-03-19 21:20:01
【问题描述】:

我在 Rails 中使用 omniauth-linkedin gem 并尝试从“r_fullprofile”和“r_network”获取数据。

在omniauth.rb 中:

  provider :linkedin, 'consumer_key', 'consumer_secret', 
       :scope => 'r_fullprofile r_emailaddress r_network', 
       :fields => ["id", "email-address", "first-name", "last-name", 
                   "headline", "industry", "picture-url", "public-profile-url", 
                   "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                   "educations", "three-current-positions" ]

在控制器中:

render :text => request.env["omniauth.auth"].to_yaml

结果输出似乎只有“r_basicprofile”的数据。如何获取解析所需数据的其余部分(例如“连接”、“技能”、“教育”)?

【问题讨论】:

    标签: ruby-on-rails-3.2 omniauth linkedin


    【解决方案1】:

    我在使用 Devise 的 Omniauth 时遇到了同样的问题。

    我必须进行更改以将 :fields => [...] 放入花括号中。

    在你的情况下:

      provider :linkedin, 'consumer_key', 'consumer_secret', 
           {:scope => 'r_fullprofile r_emailaddress r_network', 
           :fields => ["id", "email-address", "first-name", "last-name", 
                       "headline", "industry", "picture-url", "public-profile-url", 
                       "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                       "educations", "three-current-positions" ]}
    

    希望这会有所帮助。

    【讨论】:

    • 这根本不应该有所作为 - 这真的适合你吗?
    【解决方案2】:

    不知道这是否会对您有所帮助,但现在某些字段具有不同的名称。我把它放在我的 devise.rb 上,它可以工作:

    config.omniauth :linkedin, ENV['OAUTH_LINKEDIN_ID'], ENV['OAUTH_LINKEDIN_SECRET'],
    fields: %w(id email-address first-name last-name headline industry picture-url public-profile-url location num-connections), image_size: {height: 1600}
    

    connections 现在是num-connections,见Linkedin Documentation

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-27
    • 1970-01-01
    • 2015-12-25
    • 1970-01-01
    • 2015-08-29
    相关资源
    最近更新 更多