lib/omniauth/strategies/linked_in.rb in oa-oauth-0.1.6 vs lib/omniauth/strategies/linked_in.rb in oa-oauth-0.2.0.beta1

- old
+ new

@@ -2,17 +2,17 @@ require 'omniauth/oauth' module OmniAuth module Strategies class LinkedIn < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key, consumer_secret) + def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) super(app, :linked_in, consumer_key, consumer_secret, - :site => 'https://api.linkedin.com', + {:site => 'https://api.linkedin.com', :request_token_path => '/uas/oauth/requestToken', :access_token_path => '/uas/oauth/accessToken', :authorize_path => '/uas/oauth/authorize', - :scheme => :header) + :scheme => :header}, options, &block) end def auth_hash hash = user_hash(@access_token) @@ -21,11 +21,11 @@ 'user_info' => hash }) end def user_hash(access_token) - person = Nokogiri::XML::Document.parse(@access_token.get('/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location)').body).xpath('person') + person = Nokogiri::XML::Document.parse(@access_token.get('/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)').body).xpath('person') hash = { 'id' => person.xpath('id').text, 'first_name' => person.xpath('first-name').text, 'last_name' => person.xpath('last-name').text, @@ -36,10 +36,12 @@ h[element.xpath('name').text] = element.xpath('url').text h end } - hash[:name] = "#{hash['first_name']} #{hash['last_name']}" + hash['urls']['LinkedIn'] = person.xpath('public-profile-url').text + hash['name'] = "#{hash['first_name']} #{hash['last_name']}" + hash end end end end