skorks / omniauth-linkedin Goto Github PK
View Code? Open in Web Editor NEWLinkedIn OAuth strategy for OmniAuth 1.0
LinkedIn OAuth strategy for OmniAuth 1.0
I am getting the following error upon running rake
/home/raison/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S rspec ./spec/omniauth/strategies/linkedin_spec.rb
/home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- omniauth/strategies/oauth (LoadError)
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/projects/omniauth/omniauth-linkedin/lib/omniauth/strategies/linkedin.rb:1:in `<top (required)>'
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/projects/omniauth/omniauth-linkedin/lib/omniauth-linkedin.rb:2:in `<top (required)>'
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/projects/omniauth/omniauth-linkedin/spec/spec_helper.rb:8:in `<top (required)>'
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/raison/projects/omniauth/omniauth-linkedin/spec/omniauth/strategies/linkedin_spec.rb:1:in `<top (required)>'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /home/raison/.rvm/gems/ruby-1.9.2-p290@omniauth-linkedin/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
ruby /home/raison/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S rspec ./spec/omniauth/strategies/linkedin_spec.rb failed
Tasks: TOP => default => spec
(See full trace by running task with --trace)
Hi , When I click to link : user_omniauth_authorize_path(:linked_in)
I have this error, twiter fb , google and yahoo run fine
My gem:
gem 'oa-openid',:require => 'openid/store/filesystem'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-linkedin'
gem 'omniauth-yammer'
gem 'omniauth-openid' ```
I config them in devise.rb
`config.omniauth :facebook, '...', '...', :scope => 'email,user_education_history,user_work_history,offline_access'
config.omniauth :twitter, '...', '...'
config.omniauth :linked_in, '...', '...'
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('/tmp'), :require => 'omniauth-openid'
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('/tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id', :require => 'omniauth-openid'`
In user.rb I add:
`devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable ,:omniauthable`
Did I miss some config ?
Hi,
The gem works totally fine for me. Yet when extracting information from Linkedin, the public profile URL field returns this:
--- !ruby/hash:Hashie::Mashpublic_profile: http://www.linkedin.com/in/mylinkedinusername
Hmm.
How can I get just http://www.linkedin.com/in/mylinkedinusername
?
After adding the omniauth-linkedin gem, whenever I run rake in my staging environment, rake aborts when Bundler fails to load the omniauth-linkedin gem. The same thing happens if I run "bundle exec rake ...". But it works perfectly in my dev environment.
Somewhere in the process Bundler does a gsub('-', '/') and then tries to load 'omniauth/linkedin' instead of 'omniauth-linkedin', leading to the error: "no such file to load -- omniauth/linkedin"
My Gemfile has the following:
gem 'omniauth'
gem 'omniauth-linkedin'
I've verified that these gems, and their dependencies are installed in my staging environment:
Using oauth (0.4.7)
Using omniauth (1.1.1)
Using omniauth-oauth (1.0.1)
Using omniauth-linkedin (0.0.8)
rake version 0.9.2
bundler version 1.1.1
rails 3.0.4
ruby 1.9.2p180
Here is the trace:
[ruby-1.9.2]demo:/home/demo/portal/current$ rake --trace -T
rake aborted!
no such file to load -- omniauth/linkedin
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.1/lib/bundler/runtime.rb:74:in require' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.1/lib/bundler/runtime.rb:74:in
rescue in block in require'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.1/lib/bundler/runtime.rb:62:in block in require' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
each'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in require' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.1/lib/bundler.rb:119:in
require'
/home/demo/portal/releases/20121012151545/config/application.rb:7:in <top (required)>' /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' /home/demo/portal/releases/20121012151545/Rakefile:4:in
<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in load' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in
load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:495:in raw_load_rakefile' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:78:in
block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in standard_exception_handling' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:77:in
load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:61:in block in run' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in
standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in run' /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in
<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake:19:in load' /usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake:19:in
2 - 4 users per day sends user to a 404 page.
How trace this error and solve it ?
Thanks
You might get his message when you upgrade the previous version omniauth to the new 1.x one.
Note that in the new version of omniauth-linkedin, linked_in is spelled as linkedin. Updating the changes in all your codes as well as database will solved the error message above.
In my case, I got the message when i try to find an existing user authentications record in which the provider is stored as linked_in(default for the previous version).
Thought I might save some time for the other developers.
Good work skorks. thank you.
Everytime I run my Rails Server im hit with this error:
`const_get': uninitialized constant OmniAuth::Strategies::Linkedin (NameError)
Traced it to the coding where we put the
provider :linkedin <API> <SECRET>
https://developer.linkedin.com/docs/oauth2
I'm not sure when Oauth1 stopped working, I think around 3/11/2015.
Without any changes suddenly linked-in stopped working on live server - works well on local copy (the same API keys). After click connect with linkedin i see only {}:
Maybe this is something with ssl. It could be connected with changes announced in this blog post:
https://developer.linkedin.com/blog/keeping-your-applications-and-users-safe-best-practices-security
Hi,
I am getting 403, access to network denied error everytime when I try to share or fetch network updates.
I have followed the README, and used linkedin gem to call linkedin APIs.
When I used below configuration
provider :linkedin,
LINKEDIN_SETTINGS[:linkedin_api_key],
LINKEDIN_SETTINGS[:linkedin_api_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"]
I got the below error.
OAuth::Problem - Scope NOT_AUTHORIZED : r_fullprofile, Scope NOT_AUTHORIZED : r_network:
Then I have tried with the scope 'r_basicprofile r_emailaddress w_share'
provider :linkedin,
LINKEDIN_SETTINGS[:linkedin_api_key],
LINKEDIN_SETTINGS[:linkedin_api_secret],
:scope => 'r_basicprofile r_emailaddress w_share', :fields => ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location", "connections"],
It worked, but When I am trying to share or to get network updates. I am gettng 403 Access to network denied error. Even I have tried with https using ngrok.
client.add_share(share)
client.network_updates
def get_posts(credentials, options = {})
client = prepare_client(credentials["token"], credentials["secret"])
posts = client.network_updates(options)
return posts
end
private
def prepare_client(oauth_token, oauth_token_secret)
client ||= LinkedIn::Client.new(api_key, api_secret)
client.authorize_from_access(oauth_token, oauth_token_secret)
return client
end
share = {
"comment": comment,
"content": {
"title": title,
"description": description # ,
# "submitted-url": "https://developer.linkedin.com",
# "submitted-image-url": "https://example.com/logo.png"
},
"visibility": {
"code": "anyone"
}
}
client.add_share(share)
I have also tried to use the example as in your document. And that too didn't work for me.
You can now make API calls as per normal e.g.:
client.profile
client.add_share({:comment => "blah"})
In my linkedin app, I have checked all the application permissions
https://www.linkedin.com/developer/apps
Default Application Permissions:
Could you please help me on this issue?
Thanks,
Suman
Navigating to /auth/linkedin in my app after doing it once before raises a OAuth::Problem SCOPE_INVALID : r_emailaddress?scope=r_basicprofile
for me.
Looks like it's caused by the line in request_phase
, which is re-adding the scope to the path string everytime you hit the auth path again.
options.client_options.request_token_path = "#{options.client_options.request_token_path}?scope=#{options.scope}"
Changing it to
options.client_options.request_token_url = "#{options.client_options.site}#{options.client_options.request_token_path}?scope=#{options.scope}"
fixes the problem for me, but maybe it would be more clear to override OAuth's consumer method to initialize the Oauth::Consumer
with options.client_options.merge("request_token_path" => "#{options.client_options.request_token_path}?scope=#{options.scope}")
, or something like that that doesn't leave side effects on the options hash.
since linked is providing access token that expires in 60 days, Is there any helper function to update the auth token?
how to use Omniauth callback with LinkedIn API?
I'm trying to use following js code
const url = `/users/auth/linkedin/callback`;
IN.User.authorize((e) => {
this.sendRequest(url,{}); // send post request without any params
});
which sends post request after successful authorization through Linkedin API.
I, [2018-01-04T17:14:25.240777 #5985] INFO -- omniauth: (linkedin) Callback phase initiated.
E, [2018-01-04T17:14:25.375784 #5985] ERROR -- omniauth: (linkedin) Authentication failure! session_expired: OmniAuth::NoSessionError, Session Expired
That's what I got on serverside. Is there any way to achieve authorization without redirecting?
My omniauth configurations look like:
Rails.application.config.middleware.use OmniAuth::Builder do provider :linkedin, ENV["linkedin_key"], ENV["linkedin_secret"] provider :identity, on_failed_registration: lambda { |env| SessionsController.action(:new).call(env) } end
I have rechecked my key / secret value and it matches that given in the app_key section given on LinkedIn. However, today, I suddenly started getting following error:
Started GET "/auth/linkedin/callback?oauth_token=0fd17840-7b0c-4603-aa73-bf2eacf60510&oauth_verifier=29377" for 127.0.0.1 at 2013-08-04 13:55:09 +0530 (linkedin) Callback phase initiated. (linkedin) Authentication failure! invalid_credentials: OAuth::Problem, parameter_absent Processing by SessionsController#oauth_failure as HTML Parameters: {"oauth_token"=>"0fd17840-7b0c-4603-aa73-bf2eacf60510", "oauth_verifier"=>"29377"} Rendered sessions/oauth_failure.html.erb within layouts/application (0.2ms) Rendered layouts/_header.html.erb (0.2ms) Rendered layouts/_footer.html.erb (0.2ms)
Can you please suggest where I may be doing something wrong or if the issue with the gem.
We are using devise for authentication. We're using OmniAuth, but simply to authenticate once to grab a few pieces of information from LinkedIn when a user first signs up. What we've written works for the vast majority of users, however once in a while we randomly get the following error.
Authentication failure! session_expired: OmniAuth::NoSessionError, Session Expired
This error also seems to destroy the Devise session, as the user gets logged out of the system completely.
We're most likely doing something wrong, but have been unable to find any thing in forums on what might be causing this.
Any ideas?
I have configured the gem to work with omniauth and devise, however, when I try and authenticate I always get
OAuth::Problem (timestamp_refused)
Hello!
Thanks for making this gem.
I noticed that you've added "industry" and "headline" keys to the info section of the auth hash. This feels wrong, does it not? Based on my reading of the schema it seems like these values should be placed in the "extra" section.
Relocating these things may be difficult, as code has been written expecting them to exist where they are, but I wanted to open a discussion.
Hi everyone,
I have token of user and want request it to get EMAIL. HOW to config it get 'full profile' instead 'basic profile'
my code:
IN devise.rb:
config.omniauth :linkedin, "vuq..fnwb51g", "113e5p...9wpKjG5", :scope => 'r_fullprofile r_emailaddress r_network rw_nus', :fields => ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location"]
Code request:
client = LinkedIn::Client.new(config[:consumer_key], config[:consumer_secret])
client.authorize_from_access(oauth_access_token, oauth_access_token_secret)
profile = client.profile(:scope=>'r_fullprofile')
puts profile.to_json
{"first_name":"test","headline":"Student at abc","last_name":"mely","site_standard_profile_request":{"url":"http://www.linkedin.com/profile/view?id=288....80&authType=name&authToken=I3GR&trk=api*a3...21*s3344461*"}}
When upgrading to the latest version of Rails 4.2.5, we could not authenticated with LinkedIn becuase we started getting the following error:
uninitialized constant OmniAuth::Strategies::LinkedIn::MultiJson.
The list of gems is attached.
We fixed it by forking the repo and making the following change.
itcentralstation@0249f00
Hi skorks,
I have error while authorizing (on page http://domain.com/auth/linkedin): consumer_key_unknown.
Consumer Key is correct - I checked it few times. I have an omniauth.rb initializer with the following:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :linkedin, 'MY_KEY', 'MY_SECRET', :scope => 'r_network'
end
LinkedIn recently did an API update which now requires you to specify scope for permissions when requesting a token. This is documented here: https://developer.linkedin.com/documents/authentication . I've added this manually here: https://github.com/ajoneil/omniauth-linkedin/commit/e2ed7af4de16cc6be25f9d1798a0205af71f51cb . It would be good if this was able to be passed as a configuration option to omniauth-linkedin.
Thanks for this omniaouth strategy. It works great.
However, I have a small confusion when I want to read the 'Full Profile' (schools, skills, etc.) As far as I understand I would need to make an API call to get this extended information.
Now, it is here where I am a bit lost in the documentation, about how/what/where to put the access and request tokens.
I was doing a small experiment with the callback:
conn = Faraday::Connection.new('http://api.linkedin.com')
resp = conn.get " /v1/people/~", :oauth2_access_token => params[:oauth_token]
resp = conn.get " /v1/people/~", :oauth_token => token
logger.info resp.inspect
but I always get a 401 not authorized.
Do you have any hints/clarifications about what tokens can be used to access the LinkedIn API to read the full profile? Thank you very much!
LinkedIn access tokens expire after 60 days, but according to them, a token can be refreshed without user action prior to expiration (https://developer.linkedin.com/documents/authentication#handling). Is there a way to do this via the gem? I've also posted this question on StackOverflow with some more details (http://stackoverflow.com/questions/14349385/refresh-linkedin-token-with-omniauth-before-expiration).
Any information would be much appreciated. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.