I want to get a user's position information from their LinkedIn profile (company name, title, etc), but I can't get anything more than basic profile information (id, name, email, headline, and image). I'm guessins this is just a syntax thing since I'm requesting access to all fields upon user's authentication.
from user.rb
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.email = auth.info.email
user.headline = auth.info.headline
**user.company = auth.info.company**
user.avatar = auth.info.image
user.password = SecureRandom.urlsafe_base64(n=6)
user.save!
end
from devise.rb
config.omniauth :linkedin, "abcdefghijk", "abcdefghijk",
# :scope => 'r_basicprofile r_emailaddress rw_nus r_fullprofile r_contactinfo r_network rw_company_admin',
# :fields =>
:scope => 'r_basicprofile r_emailaddress rw_nus r_fullprofile r_contactinfo r_network rw_company_admin',
: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" ]
Do I need to add fields to devise.rb or am I being an idiot and formatting user.company = auth.info.company
wrong?
Thanks!
[edit] okay, found it. The devise.rb field definition is wrong. (Probably outdated, I used the same and it was copied from somewhere.)
Correct name now is just "positions", not "three-current-positions"
After that, auth.extra.info.positions
becomes available (with these params: https://developer.linkedin.com/docs/fields/positions )
访问用户信息ID的格式为:
user.name = auth["info"]["name"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.